Adding SubSecTime to file name

Started by issam9973, October 22, 2017, 04:59:50 PM

Previous topic - Next topic

issam9973

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.


- Issam

Phil Harvey

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
...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 ($).

StarGeek

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';
          },
        },
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype