add time to DateTimeOriginal and instantly create filename for AVI?

Started by Donaufisch, March 13, 2023, 12:21:10 PM

Previous topic - Next topic

Donaufisch

Hello,
I need to add time to DateTimeOriginal and instandly create the filename with this new value. The problem is, that I cannot Update DateTimeOriginal  for AVI files.  But I can create a filename from DateTimeOriginal .

For jpegs I would use:

"exiftool -DateTimeOriginal+=1:12:28 14:54:32" *.AVI
exiftool -r -d '%Y-%m-%d_%H.%M.%S%-.3nc' -ext AVI  '-filename<${DateTimeOriginal}.%e' .

For AVI Files I need to save the new DateTimeOriginal  value in a variable instead of updating it - because it is not possible- and then creating the filename from the variable value.
I tried some of these codes but didnt succeed


exiftool -r -d '%Y-%m-%d_%H.%M.%S%-.3nc' -ext AVI  '-filename<${"-DateTimeOriginal+=1:07:12 05:00:00"}.%e' .
How can I save the DateTimeOriginal value to a variable, increase the value with with1:07:12 05:00:00" and save theat variable direktly as Filename - in one line?
Or do I need to write a skript?
Can anyone help?
greetings Bob

Phil Harvey

The -globaltimeshift option makes this possible:

exiftool -r -d '%Y-%m-%d_%H.%M.%S%-.3nc' -ext AVI  '-filename<${DateTimeOriginal}.%e' -globaltimeshift '1:07:12 05:00:00' .

When shifting across months like this you should be sure the first processed file is the one that you calculated the shift for.  See the TRICKY note here for more details about this complication.

- Phil

Edit:  Hmmm.  I see a potential problem here.  If there are various conflicting date/time tags in the file then any of them may be used to initialize the shift amount, which could lead to an unpredicted shift.
...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 ($).

Donaufisch

Thanks a lot!
It works perfekt!

I just shifted the dates for renaming for about 100 AVIs and as far I can check, there was no problem!


Meanwhile I was working on an bash Skript but didn“t succseed yet.
Even if I dont need it anymore for this problem, I have still a question.
Is it possible to declare variables direkt "inline" after exiftool or "global" in a skript to pass values like DateTimeOriginal  to that variable?

In my skript I declared the variable myVar and tried to pass the value of DateTimeOriginal to my variable myvar.
-$myVar<${DateTimeOriginal} In combination with the find command, I tried to use the variable myVar value to do other things..

the whole skript:
#!/bin/sh
myVar=""     #declare a variable
searchDir='/share/Jasmin/Bilder/tmp_old'; #declare a path variable
find $searchDir -type f  -exec exiftool -$myVar<${DateTimeOriginal} '{}' \; -exec exiftool "-$myVar+=1:07:12 05:00:00" '{}' \; exiftool -r -d '%Y-%m-%d_%H.%M.%S%-.3nc' -ext AVI '-filename<${myVar}.%e' '{}' \;

# find a file, execute exifftool and copy DateTimeOriginal to $myVar, execute exifftool and add some time to variable myDate, execute exifftool and rename the originally found file with $myVar value.
#find next file and do the same...


greetings Bob
Is there any way to pass Dates to a variable? I would use it, to rename pictures with the DateTimeOriginal from a different picture.
In 2009 and 2009 the date wasnt set in one camera . So I have to rename "billions" of pics. I plan to search for coherent groups and rename them by pictureDates from another camera pics that were taken approximately at the same date.

Phil Harvey

If "myvar" is a shell variable and "datetimeoriginal" is an ExifTool tag name, then the syntax would be -$myvar'<${datetimeoriginal} -- you need to protect ExifTool tags with single quotes to prevent shell interpolation. Also, the "<" needs to be protected with either single or double quotes because it is for shell redirection. 

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