Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 6 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
4  
@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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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