Search code examples
batch-filecmdimagemagickimage-manipulationimagemagick-convert

Convert to another folder


This command works for me:

To run from cmd.exe:
convert *.jpg -set filename:f "%t.%e" "%[filename:f].png"

The same, to run from bat-file (double % instead of single):
convert *.jpg -set filename:f "%%t.%%e" "%%[filename:f].png"

Now, let's assume I have this file hierarchy:

test\
 |-- small\               <-- this is an empty folder
 |-- image1.jpg
 |-- image2.jpg

How I should modify existing script to output files in small folder, as shown below?

Current behaviour:
test\
 |-- small\
 |-- image1.jpg
 |-- image2.jpg
 |-- image1.jpg.png
 |-- image2.jpg.png

Desired behaviour:
test\
 |-- small\
      |-- image1.jpg.png
      |-- image2.jpg.png
 |-- image1.jpg
 |-- image2.jpg

I tried to use %~dp0, but with no luck currently.


Solution

  • I think I understand, but make a backup before trying:

    mogrify -path small -format png *.jpg
    

    I don't have Windows readily available to test, but in the light of your comments try:

    convert *.jpg -set filename:f "%%t.%%e" "small/%%[filename:f].png"