Change filename and shift file modify date

Started by Fulco, December 20, 2015, 08:45:09 PM

Previous topic - Next topic

Fulco

This command will only add the date and time in front of the filename. It will not shift the file modify date. Is it possible to combine it in one command?

exiftool -d %Y%m%d%H%M%S%%-c '-FileModifyDate<${CreateDate;ShiftTime($_,-2)}' '-FileName<${CreateDate}-$FileName'

Thanks in advance.

-Fulco

Phil Harvey

Hi Fulco,

You may use the -globalTimeShift option to do what you want.

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

Fulco

Hello Phil,

The tag 'globalTimeShift' does not exist and I don't think this option will do what I want. The date/time in front of the filename must be equal to the creation date/time and from the file modify date must be 2 hours removed. Is it possible to do that with one command?

- Fulco


MacBook-Air-van-Fulco:~ Fulco$ exiftool -d %Y%m%d%H%M%S%%-c '-FileName<${CreateDate}-$FileName' /Users/Fulco/Pictures/VIDEO0004.mov
    1 image files updated
MacBook-Air-van-Fulco:~ Fulco$ exiftool '-FileModifyDate<${CreateDate;ShiftTime($_,-2)}' /Users/Fulco/Pictures/20140809204827-VIDEO0004.mov
    1 image files updated
MacBook-Air-van-Fulco:~ Fulco$ exiftool -d %Y%m%d%H%M%S -filename -createdate -filemodifydate /Users/Fulco/Pictures/20140809204827-VIDEO0004.mov
File Name                       : 20140809204827-VIDEO0004.mov
Create Date                     : 20140809204827
File Modification Date/Time     : 20140809184827

Phil Harvey

Hi Fulco,

Sorry, I didn't understand what you were trying to do.  You want CreateDate in the file name, but a shifted CreateDate written to FileModifyDate.  The shift in your original command isn't working because of the date/time formatting you are applying.  Try shifting the unformatted CreateDate by adding a "#":

exiftool -d %Y%m%d%H%M%S%%-c '-FileModifyDate<${CreateDate#;ShiftTime($_,-2)}' '-FileName<${CreateDate}-$FileName'

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

Fulco


Fulco

By some trial and error I tried also to write a formatted and shifted date/time to the filename, but without result. Is that possible too?

exiftool -d %Y%m%d%H%M%S%%-c '-FileName<${CreateDate#;ShiftTime($_,+2)}' FILE

- Fulco

Phil Harvey

Yes, using the -globalTimeShift option that I mentioned earlier.

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

Fulco

Hello Phil,

The tag 'globalTimeShift' is not present in my video files (see my earlier post above). When I apply this command

exiftool -d %Y%m%d%H%M%S%%-c '-FileName<${CreateDate#;ShiftTime($_,+2)}-$FileName'

I get this result: 2014/11/27 17/55/30-VIDEO0065.mp4. The date/time formatting is not working. How can I avoid the slashes and spaces?

Is it possible to write a shifted time to the filename based on the system timezone?

MacBook-Air-van-Fulco:~ Fulco$ exiftool -createdate -filemodifydate /Users/Fulco/Pictures/VIDEO0032.mp4 /Users/Fulco/Pictures/VIDEO0065.mp4
======== /Users/Fulco/Pictures/VIDEO0032.mp4
Create Date                     : 2014:09:08 05:41:07
File Modification Date/Time     : 2014:09:08 05:41:07+02:00
======== /Users/Fulco/Pictures/VIDEO0065.mp4
Create Date                     : 2014:11:27 15:55:30
File Modification Date/Time     : 2014:11:27 15:55:30+01:00


Add 1 hour for winter time (UTC+01:00)
20140908074107-VIDEO0032.mp4

Add 2 hours for summer time (UTC+02:00)
20141127165530-VIDEO0065.mp4

Thanks in advance,
Fulco

Phil Harvey

Quote from: Fulco on December 27, 2015, 02:55:17 PM
The tag 'globalTimeShift' is not present in my video files

It is not a tag.  It is an exiftool option.  Read the exiftool documentation for details.

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

Fulco

Sorry, I wasn't aware of that option. This is the command where I was looking for:

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

Is it possible to conditionally add one or two hours based on winter time (UTC+01:00) or summer time (UTC+02:00)?

Phil Harvey

You would need to know the date when the time shift occurs.  The problem is that this will be different for different years, so the logic will be complex, but a -if condition something like this could do it:

exiftool -if "($createdate gt "2015:04:07" and $createdate lt "2015:10:21") or ($createdate gt "2014:04:10" and ...

You would then need 2 commands.  One for the summer dates and one for the winter.

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

Fulco

Thank you! To make it work, I also added a number sign to the create date.

exiftool -if '($createdate# gt "2015:03:29" and $createdate# lt "2015:10:25")' '-FileName<${CreateDate}${FileName;$_=/VIDEO/i ? "-$_" : ".%e"}' -GlobalTimeShift "+2" -d %Y%m%d%H%M%S%%-c