Hi, @steverichter , do you know if the vendor always stores the same file type? (e.g. always jpeg, or png, etc.) If so a solution could be very lean.
My approach would be to avoid FileMaker for this task because of the overhead, and go straight to a bash shell script or a python-based solution. If you know the format, you don't have to 'sniff out' the mime types, but if they're mixed one would not want to append the wrong extension, so using python's imghdr to sniff the format and append the correct extension.
Bash + file can also do this by looping through the files after you download them, or you could copy them on the server and make your own source of fully-named files on the server, depending on your workflow and storage policies of your vendor, etc.
Bash would be appropriate for use on Mac/Linux; Python is cross-platform (Windows, Mac, Linux) and more extensible if you need to do other stuff.
Sooooo... depending on your workflow, I would download the selections to a "work" folder, run the script (bash or python) and then move to the location where you access them for WP. This latter move can be part of the script as well, especially if it's a consistent pattern.
Edit to add: If some of the image files might be HEIC (or HEIF) as is typically default from iPhones now, we'd need to add a bit of complexity to the scripts to properly detect the mime type (add a python library, etc.). But since the destination is to be WP, I'd strongly suggest they get converted to JPEG or WebP anyway so that they play with Wordpress. This can be part of the script if needed.
Sorry, @steverichter , I forgot to address the movement to external server and just realized it.
As I mentioned above that adding the extension would be pretty straight forward with a shell script or python, but didn't mention that if the final destination was to be AWS or similar it can be part of the same script or a second script to it.
I created two scripts to append the extension; one Bash, one Python (actually I have a couple versions of each, as an exercise). I enjoy tinkering on this stuff sometimes. The envisioned workflow was to download the desired image files to a 'work' folder, run the script which appends the appropriate extension based on mime type (no need to know if they're all JPEG for example) and then moves the files to the 'final' folder.
Separate from this, I have a Bash script (I'm on Mac OS and Linux) that I use to access the 00:00 backup directories for FMS and copies them to AWS (for nightly offsite backups). This could be used (with modifications) to move the image files to AWS, or probably better, incorporated in the first script(s). If you want to confirm the extensions or convert HEIC (iOS images) to jpeg or png, the steps could be separate. We could also detect image mime type and convert in the same script(s) if preferred. It all really just depends if this a frequent task or a one-off, etc.
If working on Windows, Bash has additional dependencies and can be a bit 'brittle', so python would be my choice for Windows. I've not tested my scripts on Windows, but the code is portable in this case.
ALSO, while I would not use FileMaker for adding the extensions (personally, so we detect the correct file mime type), if the need includes wanting them in FileMaker one could simply import via FM script from the destination folder.
If you're interested in exploring any of this method, I'm happy to share any of it.
Thanks for the info. My vendor stores all of the files in a “jpg” folder. I’m using Windows, so I’m interested in learning Python. I’ll look for some tutorials. I appreciate your assistance.
Hi, Steve, If the files are all jpegs it’s very easy to download and append the extension. I wrote a simple Bash script to do it, but did not do a super simple one in Python. My Python script checks for all file types and such. I’m happy to share a simple python version, as well as share the more complex one with you. I’m almost lights out, but will revisit this tomorrow.
Hi, Steve, sorry for the delay in providing a Python script and guidance. My day fell apart today with some hectic client support.
I do have a Python script for you, and since you say the image files are all jpegs, it’s quite easy. I need to confirm any Windows quirks to address. It may also be prudent to test the mine type in case the vender slips another type in sometime.
My point about the FileMaker overhead was just that if you’re downloading from your client’s server and need to append the extension before using in a WP site, it makes sense to avoid the extra steps. However, if you need to catalog them in FM, they can easily be imported. I believe I’ll be free to send you a script to test tomorrow (it’s 8:00 PM at my locale now).
I (almost) always run Python scripts in a virtual environment to protect any OS Python requirements. Windows is somewhat different for this, so I’ll provide that info to you as well.
One question, 200-300 per month: Is that in one go at it, or a few times per month? If all at once, we might add batch control and run in batches of 100.
Hi, @steverichter . Here's a python script that will append the extension to JPEG files lacking extensions. I made some changes to my original version since you state you're working only with JPEG files. In my original versions I used python's 'imghdr' library, which is deprecated now and we don't know when it will be removed from future versions. I also use the Pillow library in other versions, but that requires you download and install as a dependency. We can update later if you'd like.
Not knowing your comfort with running python scripts in the command line interface, I had AI create (lazy) a verbose README file to get you started. I am not a Windows user (at all, really) so after testing the script on Mac OS and Linux, AI added the Windows-specific info.
I'm delivering it in the folder structure the script expects, but you can edit paths, folder names and such in the script.
If you find you need support for other file types, let me know. I have versions for that as well (requires other dependencies), and I'm always tweaking these things anyway. This will be fast for the batch size you mention, but if doing really large batches we'd add a batch feature to do blocks of a few hundred or whatever at a time.