I have 10,000 images in my folder. I am trying to resize them to 128 x 128.
sips -Z 128 *.jpg
is giving me this error:
-bash: /usr/bin/sips: Argument list too long
How do I fix this issue?
Assuming you are in the folder you want to process...
find ./ -name "*jpg" -exec sips -Z 128 {} \;
should work, and be processing them one by one instead of one big argument list.
You could try executing the task in a single and simple for loop:
for file in *.jpg; do
sips -Z 128 "$file"
done;
single line script:
for file in *.jpg; do sips -Z 128 "$file"; done;
Do them in smaller batches as suggested by the other answers.
Here's a third alternative that unlike the others allows you to parallelize the task. This example runs up to 4 parallel batches at a time, with a batch size of 100:
find . -name '*.jpg' -print0 | xargs -0 -n 100 -P 4 sips -Z 128
If you have a fast drive and more cores, you can increase the -P
CPU count. If you have larger images and want more fine grained batches, you can reduce the -n
batch count.