3

I am trying to make a batch file that executes the following DOS command:

exiftool "-FileName<CreateDate" -d "%Y%m%d_%H%M%S.%%e" "C:\Users\Tom\Desktop\belvedere"

(FYI, exiftool.exe is a script that extracts EXIF data from your digital photos. In the command above I am telling it to look in my desktop\belvedere directory and rename all photos with the Date_Time.extension, e.g. 20120131_113015.jpg)

If I paste the above command into the DOS command prompt, it works fine. However, if I paste this command into a text file, name it something.bat and run this batch file, it does not work well (it renames one photo to be "mHS.JPG" then gives errors. I believe that the % characters are the problem. Does anyone know how I can make a useful .bat file that runs this command?

I am using Windows 7, if this makes a difference. Thanks in advance.

7

I would venture to say you're right about the %, that's one of those characters that needs escaping. Trying replacing the % with %% for every instance.

Other than that, a .bat is just a command stored for later use, so everything else should go fine.

  • Thanks for the suggestion... this helps somewhat... the batch file now writes the command correctly up until the .%%e part – Tom Feb 1 '12 at 2:24
  • 4
    @Tom: Have you tried .%%%%e? – Brad Christie Feb 1 '12 at 2:33
  • @Tom: Not a problem. – Brad Christie Feb 1 '12 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.