Hi, I have been using exiftool recently, a great great utility! Zillion thanks Phil Harvey :)
Can someone help me correct this command. In a nutshell I would like to include "_SubSecTime" to image file name as follows:
- always use an underscore followed by three digits
- any missing digit to be padded by 0 (including the case where the subsec info is absent which results in _000)
I was using this command, would appreciate if someone can help me fix it. The command iterates over a very large photos folder.
set par_time=${DateTimeOriginal}
set dir_dst=/dst/
exiftool ^
-r -P -ext jpg ^
-d "%%Y%%m%%d_%%H%%M%%S" ^
-if "(%par_time% gt 1900/01/01)" ^
"-filemodifydate<%par_time%" "-filecreatedate<%par_time%" ^
"-filename<%dir_dst%%par_time%_${SubSecTimeOriginal;$_.=0 x(3-length)}_${ImageSize}%%-c.${FileTypeExtension}" ^
"-filename<%dir_dst%%par_time%_${SubSecTimeOriginal;$_.=0 x(3-length)}_${ImageSize}%%-c_${make;}.${FileTypeExtension}" ^
"-filename<%dir_dst%%par_time%_${SubSecTimeOriginal;$_.=0 x(3-length)}_${ImageSize}%%-c_${make;}_${model;}.${FileTypeExtension}" ^
./
note: in the actual script i am using ${MyModel;} and ${MyMake;} defined in exif config file and which replace spaces with underscores in make and model info. Would be great if there is a way to resolve the subsec time in exif config file.
The config file would maybe be a better place for this. Since you want it to always exist, you could derive a Composite tag from SubSecTimeOrginal and some other tag that always exists (like FileName), then do the formatting there. Your method of doing it on the command like should work, but you have to add three more lines with "_000" instead of SubSecDateTimeOriginal before the ones you already have to take care of the case where SubSecDateTimeOriginal is missing.
- Phil
Not extensivly tested
MySubsecond => {
Require => {0=>'FileName'}, # So tag is always processed
Desire => {1=> 'SubSecTimeOriginal'},
ValueConv => q{
return ($val[1]) ? $val[1]. 0 x(3-length($val[1])) : '000';
},
},