For %%a in ....... %%~na Batching problems with folder names - MS Windows .bat

Started by Dyfid, March 15, 2014, 06:33:03 AM

Previous topic - Next topic

Dyfid

Hi, I'm sure this has been asked but after reading the help, FAQ, documentation & searching the forum, I can't find the answer.

I use Magic Lantern raw video feature which creates individual .MLV raw files for each video clip. Each MLV file is a container holding individual .dng frames. So I have a simple script that unpacks each *.MLV to named folders, the named folders are taken from the MLV filenames, like M20-1035, so after the script has run I have perhaps 50 or so folders of dng's. All works great.

However I want to add the exif tag "Timecodes" to each dng using exiftool based on the files "DateTimeOriginal" just the %H:%M:%S bit. On the command line I can do this fine IF I name the folder of the dng's doing:

exiftool.exe -v -d %H:%M:%S "-Exif:TimeCodes<Exif:DateTimeOriginal" M20-1035

But when I attempt to do the same in a .bat file I get error:

exiftool.exe -v -d M:TimeCodes 0<Exif:DateTimeOriginal" M20-1035
The system cannot find the file specified.

If I do the following:

For %%a in (*.MLV) do exiftool.exe -v  "-Exif:TimeCodes<Exif:DateTimeOriginal" -d %H:%M:%S %%~na

It fails on the final folder name. Error message:

"The following usage of a path operator in batch-parameter substitution is invalid: %~na"

If I substitute %%~na for the folder name M20-1035 the .bat script works. But Timecodes are all 00:00:00, I guess due to me moving the -d %H:%M:%S bit.

Can I use the -directory= option in some way or is this more about MS Windows syntax rather than exiftool? How would I solve this?

Phil Harvey

In a Windows .BAT file, all "%" characters need to be doubled.  Perhaps this is your problem.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Dyfid

Woosh! Just like that. :) Done. Adding the double % to HMS did the job. Many thanks. Gotta get the BWF .wav sidecars fed with the exif timecodes via BWFMetaEdit next. :)

For %%a in (*.MLV) do exiftool.exe -v -d %%H:%%M:%%S "-Exif:TimeCodes<Exif:DateTimeOriginal" -overwrite_original %%~na