exiftool and windows: how to handle % ?

Started by juju22, April 21, 2012, 08:08:01 PM

Previous topic - Next topic

juju22

probably seen elsewhere but didn't find.

I'm trying to make this unix command in its windows counterpart

exiftool $exiftool_arg '-filename<CreateDate' -d $Images/%Y%m%d/%Y%m%d_%H%M%S%%-c--%f.%%ue -r -P -ext JPG -ext NEF -ext AVI -ext MP4 $Todo



%exiftool% %exiftool_arg% '-filename<CreateDate' -d '%Images%\\%Y\%m%d\\%Y\%m\%d_\%H\%M\%S\%\%-c--\%f.\%\%ue' -r -P -ext JPG -ext NEF -ext AVI -ext MP4 %Todo%

=> NOK

it seems there is a problem with <CreateDate and %. I also try %% with no luck.

Thanks:
Cheers

Julien


Phil Harvey

Hi Julien,

For windows, just use double quotes (") instead of single quotes (').

If used in a BAT file, you must also replace all % with %%.

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

juju22

ok  that was double quote
got it running with

%exiftool% %exiftool_arg% "-filename<CreateDate" -d "%Images%\%%Y%%m%%d\%%Y%%m%%d_%%H%%M%%S%%%%-c--%%f.%%%%ue" -r -P -ext JPG -ext NEF -ext AVI -ext MP4 %Todo%

(also removed '()' from exec filename9
but with errors


======== G:/Photos_temp/d90/101NCD90/DSC_0110.JPG
Setting new values from G:/Photos_temp/d90/101NCD90/DSC_0110.JPG
Writing File:FileName
'G:/Photos_temp/d90/101NCD90/DSC_0110.JPG' --> 'G:/Photos_temp_target/%Y%mG:/Pho
tos_temp/d90/101NCD90/%Y%mG:/Photos_temp/d90/101NCD90/_%H%M%S%--DSC_0110.%JPG'
Error creating directory G:/Photos_temp_target/%Y%mG:
Warning = Error creating directory for 'G:/Photos_temp_target/%Y%mG:/Photos_temp
/d90/10[snip]
Warning: Error creating directory for 'G:/Photos_temp_target/%Y%mG:/Photos_temp/
d90/101NCD90/%Y%mG:/Photos_temp/d90/101NCD90/_%H%M%S%--DSC_0110.%JPG' - G:/Photo
s_temp/d90/101NCD90/DSC_0110.JPG


for unknown reason %d is transformed in parent dir and not day as under unix ???

Thanks a lot Phil.

Phil Harvey

Are you running this command from a .bat file or not?  It seems as if you aren't, in which case the % characters shouldn't be doubled.  In the -d format string on the command line, %%d will give the directory name of the source image (when used in a file name).  In a .bat file, this should be %%%%d, so since it is working with %%d it looks like you aren't using a .bat file.  Also, %%Y and %%m aren't being expanded properly, which makes sense if this command isn't run from a .bat file.  But then I don't understand the %exiftool%, because this looks like a .bat file variable to me.

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

juju22

I'm using a bat file. why %d is different between win & linux ? call system date ?

I tried 4 % for d only or all Ymd but with no luck


%exiftool% %exiftool_arg% "-filename<CreateDate" -d "%Images%\%%%%Y%%%%m%%%%d\%%%%Y%%%%m%%%%d_%%H%%M%%S%%%%-c--%%f.%%%%ue" -r -P -ext JPG -ext NEF -ext AVI -ext MP4 %Todo%
=>
======== G:/Photos_temp/d90/101NCD90/DSC_0012.JPG
Setting new values from G:/Photos_temp/d90/101NCD90/DSC_0012.JPG
Writing File:FileName
'G:/Photos_temp/d90/101NCD90/DSC_0012.JPG' --> 'G:/Photos_temp_target/%%Y%%m%G:/
Photos_temp/d90/101NCD90/%%Y%%m%G:/Photos_temp/d90/101NCD90/_%H%M%S%--DSC_0012.%
JPG'
Error creating directory G:/Photos_temp_target/%%Y%%m%G:
Warning = Error creating directory for 'G:/Photos_temp_target/%%Y%%m%G:/Photos_t
emp/d90[snip]
Warning: Error creating directory for 'G:/Photos_temp_target/%%Y%%m%G:/Photos_te
mp/d90/101NCD90/%%Y%%m%G:/Photos_temp/d90/101NCD90/_%H%M%S%--DSC_0012.%JPG' - G:
/Photos_temp/d90/101NCD90/DSC_0012.JPG


why %d is the only one expanded whatever escaping there is ?

Phil Harvey

Wow.  You are confused.  In a date-time format string, all file-name parameters need double % (this is %d, %f, %e, %c).  In a .bat file, all % characters need to be doubled.  So this is what you need in a .bat file:

%exiftool% %exiftool_arg% "-filename<CreateDate" -d "%Images%\%%Y%%m%%d\%%Y%%m%%d_%%H%%M%%S%%%%-c--%%%%f.%%%%ue" -r -P -ext JPG -ext NEF -ext AVI

Here you don't want %%%%d because that would be the file directory.  %%d is the day of the month.

The use of % is the same for Windows and Linux.  But in a .bat file it is different because the % is used for batch file variable names.  So in a .bat file, all % characters need to be escaped as %%.

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

juju22