I have very specific question.

I've got 500,000 images that sit in 98 subfolders. Some of the subfolders contain 25,000 images.

Is there any script/automator workflow that I can use?

I was trying to create a workflow:

  1. Ask for Finder Items
  2. Get Folder Contents (tick repeat for each subfolder found)
  3. Rotate images

It works OK, but only for these folders where there is less than 4,096 files: I normally receive following error message:

Rotate images failed - 1 error too many arguments (12019) -- limit is 4096

Is there any way to increase this limit or create completely different apple script? I really hope that someone will help me with this one.


If you're not bound to use Automator or AppleScript, simply use ImageMagick through the shell. You can install ImageMagick through MacPorts, Homebrew, or the official distribution.

To do this, we'll call find. If you want to see the names of the images first, before actually converting them, insert an echo between -execdir and convert.

Here's the command:

find /some/path/ -type f -iname "*.jpg" -execdir convert {} -rotate 90 rot_{} \;

This will recursively …

  • search /some/path
  • for files
  • with the name *.jpg
  • call convert from ImageMagick, with the working path set to the image's one (execdir)
  • rotate them 90 degrees
  • save them under rot_ + the original filename

Since find will call convert for each image separately, it doesn't matter how many files there actually are.


You can simply use sips...

Assuming every file in the folders is an image file:

set mainFolder to POSIX path of (path to desktop as text) & "My Folder"
do shell script "find " & quoted form of mainFolder & " \\! -name \".*\" -type f -print0 | xargs -0 sips -r 90"

You can use jpegtran to rotate images losslessly. It can be installed with brew install libjpeg.

for f in $(find ~/Folder -iname '*.jpg'); do
    /usr/local/bin/jpegtran -rotate 90 "$f" > "$f.temp"
    [[ $? == 0 ]] && mv "$f.temp" "$f" || echo "$f"

Another option is Hazel. You tell Hazel which folders (and subfolders) to check, set up the criteria for files to be acted upon, and the actions to take (including scripts, shell scripts and workflows) and Hazel does the rest.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.