ExifTool Forum

ExifTool => Newbies => Topic started by: DeltaTango on December 23, 2023, 08:32:23 AM

Title: CreateDate from filemodifydate with -2h shift
Post by: DeltaTango on December 23, 2023, 08:32:23 AM
Sorry,

for the easy question but I didn't found an easy solution:

"-datetimeoriginal<filemodifydate-02:00"
didn't work

Title: Re: CreateDate from filemodifydate with -2h shift
Post by: StarGeek on December 23, 2023, 10:37:31 AM
That's because putting "-02:00" at the end of a time stamp is the format for a time zone.  And the FileModifyDate tag already includes a timezone.  So what you're basically copying would be something like "2023:12:23 12:00:00-08:00-02:00".

To shift the time for all date/time tags, you would use the -GlobalTimeShift option (https://exiftool.org//exiftool_pod.html#globalTimeShift-SHIFT).
exiftool -GlobalTimeShift -2 "-DateTimeOriginal<FileModifyDate" /path/to/files/

Or, if you were copying other time stamps and only wanted to change this one, you would use the ShiftTime helper function (https://exiftool.org//exiftool_pod.html#Helper-functions)
exiftool "-DateTimeOriginal<${FileModifyDate;ShiftTime('-2')}" /path/to/files/
Title: Re: CreateDate from filemodifydate with -2h shift
Post by: DeltaTango on December 23, 2023, 10:49:17 AM
ahh ok, many thanks. And when I want to change the filename with an offset of two hours I tried this

"-filename<${createdate;ShiftTime("2")} -d %Y%m%d_%H%M%S.%%e"
I got following message:

Warning: New file name not allowed in Windows (contains ':') - 20170927(085822).mp4
Title: Re: CreateDate from filemodifydate with -2h shift
Post by: StarGeek on December 23, 2023, 11:44:54 AM
Your quotes are all messed up.  You changed the single quotes in my example into double quotes and then you didn't have a closing double quote.

Example where I used TestName instead of FileName
C:\>exiftool "-testname<${createdate;ShiftTime('2')}" -d "%Y%m%d_%H%M%S.%%e" y:\!temp\Test4.jpg
'y:/!temp/Test4.jpg' --> 'y:/!temp/20231222_120000.jpg'
    0 image files updated
    1 image files unchanged

In Windows CMD, single quotes are used on anything that needs quotes when surrounded by double quotes. 
"-testname<${createdate;ShiftTime('2')}"

On Mac/Linux, it's the reverse
'-testname<${createdate;ShiftTime("2")}'
Title: Re: CreateDate from filemodifydate with -2h shift
Post by: DeltaTango on December 24, 2023, 08:06:10 AM
Ok - it's a lot of stuff you have in brain und very complicate to remember for me :)

The filename is now the createdate, but without +2h

exiftool -api LargeFileSupport=1 -d "%Y%m%d_%H%M%S_%%C.%%e" "-testname<${createdate;shifttime('2')}" 20170718_145706.MP4
Warning: Undefined subroutine Image::ExifTool::shifttime called for 'createdate' - 20170718_145706.MP4
'20170718_145706.MP4' --> '20170718_145706_0.MP4'
    0 image files updated
    1 image files unchanged

Merry X-mas

Dirk
Title: Re: CreateDate from filemodifydate with -2h shift
Post by: StarGeek on December 24, 2023, 10:28:23 AM
The case matters for helper functions.  You need to use ShiftTime, not "shifttime".