I have the two folders under the same level directory folder1 and folder 2 now I try to convert all images in folder1 to folder2 and with same file name. here is what i have now:
for f in folder1/*.jpg
do
convert $f -resize 80%X80% +profile "*" -quality 85 folder2/$f
done
and it throws the following message from each file it tried to convert: convert: unable to open image `folder1/folder2/st-3474827-1.jpg': No such file or directory @ blob.c/OpenBlob/2440.
and I know its directory problem but google for two days already still dont know how to fix it. Can you help me with this?
There's two ways you could deal with it.
Use mogrify
:
mogrify -path folder2 -thumbnail 50x50 folder1/*.jpg
Use basename
:
for filename in folder1/*.jpg; do
basename="$(basename "$filename" .jpg)"
convert "folder1/$basename.jpg" -thumbnail 50x50 "folder2/$basename.jpg"
done
The former option is probably better, but the latter may be clearer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With