I have used this Automator script to sort (image) files into folders by date (from EXIF data) written by forum user VikingOSX for years. Suddenly it gives me this error:
What may be the problem?
I have reinstalled ExifTool and restarted my computer.
I have used this Automator script to sort (image) files into folders by date (from EXIF data) written by forum user VikingOSX for years. Suddenly it gives me this error:
What may be the problem?
I have reinstalled ExifTool and restarted my computer.
Posted on Oct 3, 2026 10:37 AM
Oct 3, 2026 12:13 PM in response to VikingOSX
OK, so I tried removing the files I was trying to process (about 900 files) from the folder in question and then adding back and processing a few at a time. Turns out the script worked with all files but two. Perhaps those files are corrupt and that's the whole problem?
Oct 3, 2026 12:37 PM in response to TZW
Does EXIFTool show any of the fields used in the Ruby script for those JPGs? Perhaps some EXIF metadata is missing.
Oct 4, 2026 10:24 AM in response to TZW
The Ruby script is attempting to pass an empty create_date string into the FileUtils.mkdir function and that being taboo, blows up the script. Something is amiss in the code that is not obtaining the creation_date, whether ExifTool, or pure Ruby. Stay tuned as I am testing it with your IMG_8213.JPG image.
Oct 3, 2026 12:50 PM in response to VikingOSX
The files are missing DateTimeOriginal and maybe more.
Oct 4, 2026 11:11 AM in response to TZW
Ok, I managed to process your preceding image and created a folder for it. This required some thought about:
So here is the revised Ruby script.
Oct 3, 2026 11:24 AM in response to TZW
No help will be forthcoming without seeing the Ruby script and the Automator workflow to test in a current version of EXIFTool and Golden Gate. Apple has hardly updated Ruby v2.6 in years…
Oct 3, 2026 11:38 AM in response to VikingOSX
No help will be forthcoming without seeing the Ruby script and the Automator workflow to test in a current version of EXIFTool and Golden Gate. Apple has hardly updated Ruby v2.6 in years…
Both FileUtils.mkdir and FileUtils.mkdir_p work with the System Ruby v2.6.10.p210 in macOS 27.0.1. The first makes a single directory and the second makes interim folder hierarchy with this syntax:
#!/usr/bin/ruby
require 'fileutils'
singleFolder = File.expand_path('~/Desktop/Foo')
hierFolder = File.expand_path('~/Desktop/Bar/Baz/Foo')
FileUtils.mkdir singleFolder
FileUtils.mkdir_p hierFolder
Oct 3, 2026 12:16 PM in response to TZW
Do those two unprocessed files have extensions that are omitted in that Ruby extensions set? Can you open those two martian files in Apple's Preview or Quick Look?
Oct 3, 2026 12:12 PM in response to TZW
I replaced your first action in your Automator application:
With:
No Ruby code was changed. When I ran this updated Automator application, aimed it at a folder on my Desktop containing five random image picks, it generated the following folder results without any error:
Tested: macOS 27.0.1, M4 Mac Mini Pro.
Oct 3, 2026 12:23 PM in response to VikingOSX
They are .JPG and yes they can be opened by Apple's Preview or Quick Look. Both of them were edited with the iPhone app SimplyBW, but I'm sure there were more of that kind in the batch ...
Anyway, seems like your script was not to blame :-)
Oct 4, 2026 5:41 AM in response to TZW
If for some reason, ExifTool returns no date string from the image file, the script will still return the birthtime (Finder creation date) of the image. If there are multiple date strings found by ExifTool, then the first one will be used. I don't see how this script would fail to get some date from a given image file, if not in the image metadata.
Oct 4, 2026 5:51 AM in response to VikingOSX
If you want to dig deeper, here's one of the image files that triggers the error: https://www.dropbox.com/scl/fi/4lp5jkioq0jlgpqpu8uru/image.zip?rlkey=kr8uyplzfszi9zyfj301fjb2f&st=3a1mxg9n&dl=0
Oct 3, 2026 11:41 AM in response to VikingOSX
Thanks for checking in! Here's the Automator workflow I've been using.
Oct 3, 2026 12:04 PM in response to VikingOSX
To add, I found the ivfolders.rb script and ran it from the Terminal against a folder containing 7 test images.
Creating six folders based on image creation date.
Oct 4, 2026 12:17 PM in response to VikingOSX
The new script works for me as well. Thank you very much for looking into this and sharing your time and knowledge, much appreciated:-)
Oct 4, 2026 1:50 PM in response to TZW
You are welcome.
Originally posted at discussions.apple.com/thread/256369764