Time differences in renaming files via scripts in Windows and Linux

Started by tooremex, July 20, 2022, 07:18:29 AM

Previous topic - Next topic

tooremex

Hi guys,
I use exiftool to rename photos and videos with date and time taken.
I do this in Windows with a batch script and in Linux with a bash script.
Unfortunately there are differences in the video file names.
The Windows batch script works correctly, but the file names, created in Linux, show me the time 2 hours erarlier. I only have the phenomenon when renaming AVI videos, but not with photos.

Here are the commands from the scripts:


rem *** Windows ***
rem * photo
start "" C:\Users\username\Programme\exiftool-12.41\exiftool.exe -d PIC_%%Y%%m%%d_%%Hh%%Mm%%Ss%title%.%%%%e "-FileName<DateTimeOriginal" G:\photos\DSCF*.JPG
rem * video
start "" C:\Users\username\Programme\exiftool-12.41\exiftool.exe -ext+ AVI -d VID_%%Y%%m%%d_%%Hh%%Mm%%Ss%title%.%%%%e "-FileName<FileModifyDate" G:\photos\DSCF*.AVI


and


'*** Linux ***
# photo
exiftool -'filename<DateTimeOriginal' -d PIC_%Y%m%d_%Hh%Mm%Ss"$itle".%%e DSCF*.JPG
# video
exiftool -ext+ AVI -'filename<FileModifyDate' -d VID_%Y%m%d_%Hh%Mm%Ss"$title".%%e DSCF*.AVI


What can I do to solve this problem?

Thank you for your help.

Sincerely

Phil Harvey

you don't need to use -ext+ AVI if you are specifying the file names specifically.  This option is used when specifying directory names.

I don't know why your filesystem date/times are shifted, but perhaps your system time zone is set wrong?

You can work around this with the exiftool api GlobalTimeShift option if necessary.  ie) -api globaltimeshift=2

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

tooremex

Hello Phil,

thank you for your answer and tip. I will heed ist.

But, are you agree with me, that both commands for renaming the video files generally do the same?

Of course I will try or use the GlobalTimeShift option.

Best regards

Phil Harvey

The commands are the same for Windows and Linux.  The difference is the system's handling of file timestamps.

It may also depend on the filesystem you are using.  If you copy files to a FAT32 volume, you can lose the time zone information since Linux stores timestamps in UTC and FAT32 uses local time (I believe).  Anyway, Windows' handling of time zones is generally very poor.

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

tooremex

Hello Phil,

thank your for your answer again.

"The difference is the system's handling of file timestamps."

Ah, that explains the differences in my renaming results.

Now, I could solve my problem with the GlobalTimeShift option. But I have to use -api globaltimeshift=2.

That works fine for me.

Thank you for your help.

Best regards

tooremex

Oh, I just saw it now, that I did a misstake recently.

My useful command is -api globaltimeshift=-2.

I forgot the minus.

obetz

Quote from: Phil Harvey on July 20, 2022, 01:54:02 PMThe commands are the same for Windows and Linux.  The difference is the system's handling of file timestamps.

where "system" means OS + Perl: ActivePerl had a DST handling bug. I don't remember whether this bug still exists nor whether Strawberry Perl has the same problem.

Phil Harvey

Windows alone has well-documented time zone problems (just using the "dir" command).  I wasn't aware of the difference between ActivePerl and Strawberry Perl.

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

obetz

Quote from: Phil Harvey on July 31, 2022, 09:25:54 PMI wasn't aware of the difference between ActivePerl and Strawberry Perl.

I'm not sure whether there is a difference between these two.

IIRC, Cygwin Perl is not affected, Activestate is affected.