0

I have an exe application that takes in 2 parameters. One is a input file path with an specific extension (e.g. *.jpg) and Second is the output file path.

Now in a folder, I have let's say 100 jpeg images which I want to pass in continuously and saved the output with the same file name as the input (extension will be different, the exe does the conversion).

Any idea how do I write a batch file to achieve this?

Thanks and Regards, Perumal

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
perumal316
  • 1,159
  • 6
  • 17
  • 36

1 Answers1

1

Try this:

@FOR %%1 IN (%1) DO convert %%1 %2\%%n1.png

To be used as:

bulkconvert c:\test\*.jpg c:\test

It'll call convert for each file that matches the search pattern c:\test*.jpg and a 2nd parameter will be provided with the path provided as batch's 2nd parameter (note: there is not the trailing backslash) with the same file name but with extension png.

As reference: How to get folder path from file path with CMD

Community
  • 1
  • 1
Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
  • +1, That is a reasonable guess as to what the arguments should be to the unnamed exe. Obviously the actual syntax may have to change depending on the exe requirements of the exe. – dbenham May 11 '12 at 11:32
  • Hi Adriano, thanks for the fast reply. I tried but could not get it to work. Not sure whether I am doing anything wrong. It is like I want to pass in all files that will end with *.jpg from a path and the output will all end with *.png. How do I specify this? – perumal316 May 11 '12 at 11:37
  • If your exe will manage to change extension (and that parameters order is ok for it) you can use something like this: "batchfilename c:\inputpath\*.jpg c:\outputpath". It'll call your exe for each file JPG in c:\inputpath (and your exe will manage to save it with the right name inside c:\outputpath) – Adriano Repetti May 11 '12 at 11:55
  • Hi Adriano, this could work but the issue is for the output I need to also specify the extension and when I tried batchfilename c:\inputpath\*.jpg c:\outputpath\*.png" it is not saving. Meaning for example for 1 file, I need to pass in test.jpg and test.png in order for the exe to do the conversion. Not sure how this can be done now for batch for a lot of files? – perumal316 May 11 '12 at 12:43