Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 7 down vote accepted

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.

share|improve this answer
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
@Tom: Have you tried .%%%%e? – Brad Christie Feb 1 '12 at 2:33
That did it! Thanks!! – Tom Feb 1 '12 at 2:41
@Tom: Not a problem. – Brad Christie Feb 1 '12 at 2:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .