News:

If this site goes down it is because of the crappy DreamHost web hosting: They will disable your "unlimited traffic" web server if a single bot hammers the site with a moderate load.  If necessary, an alternate ExifTool forum page is available at https://sourceforge.net/p/exiftool/discussion/

Main Menu

Batch rename .m4a files with CreateDate + 2 hours

Started by pdeli, August 03, 2022, 12:09:28 PM

Previous topic - Next topic

pdeli

Dear ExifTool team,

I am trying to batch rename .m4a files with the creation date. Thanks to two forum threads here at exiftool.org and one in photo.stackexchange.com, I managed to get to this point:
exiftool '-FileName<CreateDate' -d '%Y%m%d %H%M%S.%%e' .
However, because the files have been created at GMT+02:00, I'd like to add 2 hours to the CreateDate.

Can someone please let me know what code I have to use for that?

Thanks in advance and best regards,
pdeli

System used:
  • exiftool version 12.42
  • macOS Monterey 12.5 (Intel)

Sources:
https://photo.stackexchange.com/questions/103767/how-can-i-rename-files-to-match-their-exif-created-date
https://exiftool.org/forum/index.php?topic=7982.0
https://exiftool.org/forum/index.php?topic=11327.0

++++

Jom

I only have Windows.
On PowerShell it is like this:
exiftool -CreateDate+=2 -ext m4a .
exiftool -FileName<CreateDate -d '%Y%m%d %H%M%S.%%e' -ext m4a .
On CMD it like this:
exiftool -CreateDate+=2 -ext m4a .
exiftool "-FileName<CreateDate" -d "%Y%m%d %H%M%S.%%e" -ext m4a .

See also:
https://exiftool.org/exiftool_pod.html#Tag-operations
https://exiftool.org/exiftool_pod.html#WRITING-EXAMPLES

StarGeek

#2
One thing to remember is that in videos, CreateDate is supposed to be in UTC.  It you change the embedded CreateDate by adding two hours to it, then Windows Properties->Details->Media created time will be off.

If you want to add the two hours to the tag, then @Jom has the right command.  But I recommend against it if the time is properly set to UTC.

When it comes to renaming, if the CreateDate is properly set to UTC and you are in the same +02:00 time zone, then all you need to do is add the -api QuickTimeUTC option to your command
exiftool '-FileName<CreateDate' -api QuickTimeUTC -d '%Y%m%d %H%M%S.%%e' .

Otherwise, you can use the GlobalTimeShift option
exiftool '-FileName<CreateDate' -GlobalTimeShift 2 -d '%Y%m%d %H%M%S.%%e' .

Edit: Don't know why I assumed Windows but Macs also correctly understand that a video is supposed to be UTC and will adjust the displayed time as well.
Troubleshooting hints:
* Did you read FAQ #3 and use the command listed there?
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.

Jom

Absolutely right, the date and time must be kept in accordance with the standard. It also seemed strange to me to want to increase the time instead of specifying UTC, but I thought that the person knows what he is doing.

Format is this:
YYYY-MM-DDThh:mm:ss.s[+/-]00:00
0000-00-00T00:00:00.000[+/-]00:00
Example:
2022-08-03T21:40:25.543-10:00
Lock here, for example:
https://iptc.org/std/photometadata/specification/IPTC-PhotoMetadata#date-value-type

pdeli

Thanks for all the answers.

I now realise that the wording of the initial post was poorly phrased. Sorry.

What I would like is to use the data found in CreateDate and add/subtract local time and push the result into a filename. Therefore, I don't want to tamper with CreateDate, I just want to use the data in CreateDate to generate a filename.

In other words
  • Extract Creation Date
  • Add/Subtract Local Time
  • Rename the original files (i.e., 'YYYYMMDD hhmmss.extension', where YYYYMMDD hhmmss = CreateDate +/- local time)

The piece of code of the initial post does the job, except that I live in Z+02:00 and as a nice to have, I wanted the date to reflect that. As a nice to have, it would be cool that Z reflects variable local time, not hard coded, but only as a nice to have.

Phil Harvey

StarGeek gave a command that does this using the -globalTimeShift option.

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

pdeli

That's the one:
exiftool '-FileName<CreateDate' -GlobalTimeShift 2 -d '%Y%m%d %H%M%S.%%e' .
It worked exactly as I wanted!

Thank you very much for your support  :)