Conditionally rename file

Started by Fulco, December 24, 2015, 05:55:34 AM

Previous topic - Next topic

Fulco

Is it possible to integrate these two commands into one? I tried it with IF- and Or-statements, but I can't get it to work.

exiftool -if 'not $FileName =~/VIDEO/i' '-FileName<${CreateDate}.%e' -d %Y%m%d%H%M%S%%-c

exiftool -if '$FileName =~/VIDEO/i' '-FileName<${CreateDate}-$FileName' -d %Y%m%d%H%M%S%%-c


Thanks in advance,

Fulco

Phil Harvey

Hi Fulco,

The -if option either processes a file or not.  It doesn't allow different processing for different files.

But you should be able to do what you want like this:

exiftool '-FileName<${CreateDate}${FileName;$_=/VIDEO/i ? "-$_" : ".%e"}' -d %Y%m%d%H%M%S%%-c

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

Fulco

Many thanks! I couldn't figure it out by myself.

- Fulco

Fulco

This command will only work when the filename contains "VIDEO". Is it possible to add conditionally the CreateDate in front of the filename when it contains "VIDEO", "IMG" or "MVI"? I can't find any logic to make it work.

exiftool '-FileName<${CreateDate}${FileName;$_=/VIDEO/i ? "-$_" : ".%e"}' -api QuickTimeUTC -d %Y%m%d%H%M%S%%-c

- Fulco

Phil Harvey

Hi Fulco,

Replace VIDEO in the regular expression with (VIDEO|IMG|MVI)

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

Fulco