It’s super simple to add files to Salesforce. Just drag and drop. Easy as pie. But if you need to get those files out of Salesforce, it can be a challenge. As an admin or developer, there isn’t an interface that allows you to simply select the Files and download them.
Recently, I had to produce files related to a specific custom object. I tried several different options to get to the Files I needed. I tried the Data Export option, but that didn’t allow filtering. I tried going through Premier Support Admin Services, but it’s not option. I was referred to AppExchange apps, but they were all outdated or came with a price tag. I tried Data Loader, too, but no luck. Then, I ran across a comment from Johan Karlsteen on the developer forum saying that he had built a python script to make this work. (His blog on this topic.) He also shared the code on github. His solution was exactly what I needed.
To meet my specific use case, I made a few changes to the code. To reduce API calls, I added some batching capabilities. To help with mapping the files to their related records I added a file mapping csv export. And I added some logic to remove strings from the file name that would break the file writing process.
If you’re struggling with the same scenario, I highly recommend this method. It can save a lot of time and effort!