Argument too long even with quotes
Posted: 2012-01-05T14:59:30-07:00
I've been using the shell below to take a series of images and make two, differently edited images of each original. Until now it worked fine but upon trying it on a batch of ~2000 images now, I'm getting the error "Argument list too long". I have since edited the code to include the quotes you see around the wildcards as you can see now but the error is still appearing (no longer for the first mogrify, but now for the covert operations so it looks like it has something to do with the 'f in "*.png"' business).
I suppose I could break the operation into smaller chunks but I would prefer to do it all at once and just leave the computer while it works. Any thoughts? Thanks for the help.
I suppose I could break the operation into smaller chunks but I would prefer to do it all at once and just leave the computer while it works. Any thoughts? Thanks for the help.
Code: Select all
#!/bin/bash
if [ ! -d ./Hero ]; then mkdir ./Hero;
fi
if [ ! -d ./Gallery ]; then mkdir ./Gallery;
fi
echo "Converting .jpg's..."
mogrify -format png "*.jpg"
echo "Converting .psd's..."
mogrify -format png *.psd[1]
echo "Converting .gif's..."
mogrify -format png *.gif
echo "Converting .tif's..."
mogrify -format png *.tif
echo "Conversion Complete; now formatting..."
for f in "*.png";
do
echo "Formatting image as hero shot: $f"
convert -set density 38 -units PixelsPerCentimeter \
-bordercolor white -border 1x1 \
-alpha set -channel RGBA -fuzz 3% \
-fill none -floodfill +0+0 white \
-shave 1x1 \
-blur 0x.3 \
-trim +repage \
-resize 230x375 \
$f ./Hero/$f
done
echo "Process complete; Hero shots created in folder: Hero"
for f in "*.png";
do
echo "Formatting gallery image: $f"
convert -set density 38 -units PixelsPerCentimeter \
-bordercolor white -border 1x1 \
-alpha set -channel RGBA -fuzz 1% \
-trim +repage \
-resize 950x800 \
-background white -gravity center -extent 1920x1080+1-50 \
$f ./Gallery/$f
done
echo "Images formatted; now converting to .jpg"
cd Gallery
for f in "*.png";
do
echo "Converting gallery image: $f"
mogrify -format jpg "*.png"
done
echo "Removing temporary files..."
rm *.png
cd
rm *.png
rm *.jpg
rm *.gif
rm *.psd
echo "Process complete; Gallery images created in folder: Gallery; Hero shots created in folder: Hero"
echo -e "\a"