ExifTool Forum

ExifTool => Newbies => Topic started by: Fulco on December 24, 2015, 05:55:34 AM

Title: Conditionally rename file
Post by: Fulco on December 24, 2015, 05:55:34 AM
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
Title: Re: Conditionally rename file
Post by: Phil Harvey on December 27, 2015, 11:53:42 AM
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
Title: Re: Conditionally rename file
Post by: Fulco on December 27, 2015, 03:04:34 PM
Many thanks! I couldn't figure it out by myself.

- Fulco
Title: Re: Conditionally rename file
Post by: Fulco on February 22, 2016, 08:02:38 AM
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
Title: Re: Conditionally rename file
Post by: Phil Harvey on February 22, 2016, 08:14:05 AM
Hi Fulco,

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

- Phil
Title: Re: Conditionally rename file
Post by: Fulco on February 23, 2016, 06:16:52 AM
It works! Thanks again.

- Fulco