Filename with -fileorder Create Date OR Media Create Date

Started by davidcpreston, February 16, 2025, 11:43:43 AM

Previous topic - Next topic

davidcpreston

I use the command in a Windows bat file and it works wonderfully on jpgs:-
exiftool.exe -fileorder CreateDate "-filename<CreateDate" -m -d "%%Y %%B %%d %subtext% (%%%%-1C).%%%%e" *.*

BUT, I usually have mp4 files in the folder too, and they get the last sequence number as they don't contain the Create Date, so is there a way to use -fileorder CreateDate OR MediaCreateDate?

StarGeek

No, there is no "or" in the -FileOrder option.

You would have to use two separate command and the -ext (-extension) option

exiftool.exe -ext mp4 -fileorder MediaCreateDate"-filename<MediaCreateDate" -m -d "%%Y %%B %%d %subtext% (%%%%-1C).%%%%e" *.*
exiftool.exe --ext mp4 -fileorder CreateDate"-filename<CreateDate" -m -d "%%Y %%B %%d %subtext% (%%%%-1C).%%%%e" *.*

Note that in the second command, I use --ext instead of -ext. The first command renames all the MP4s. The second command renames all files except the MP4s.

Another option would be to first make sure all the file with a 0000:00:00 CreateDate were correct. Something like
exiftool "-if $Createdate=~/0000:00:00/" "-CreateDate<MediaCreateDate" /path/to/files/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

davidcpreston

First of all thank you for the amazingly quick response.
The mp4s don't have a create date tag, it's media create date, otherwise I wouldn't have the problem.
Whichever way I do it, I wouldn't end up with the files in the order they were take. All I do at the moment is manually change the sequence number of the mp4 to the same as the jpg that I took before it and it works, was just hoping to do it automatically in 1 sweep

StarGeek

Quote from: davidcpreston on February 16, 2025, 12:04:36 PMThe mp4s don't have a create date tag, it's media create date, otherwise I wouldn't have the problem.

All MP4 have a CreateDate. It's a required tag for MP4s. But if it is not set, they will contain a date of "0000:00:00 00:00:00". The command I listed renamed MP4 files by the MediaCreateDate and all other files by the CreateDate

But if they were videos directly from a camera, it would be extremely unusual to have a 0000 CreateDate, yet have a different value in the MediaCreateDate.

QuoteWhichever way I do it, I wouldn't end up with the files in the order they were take.

Video time stamps are supposed to be set to UTC, so they shouldn't end up next to the correct JPEGs unless other options were added. Adding the -api QuickTimeUTC option will convert the time stamp from UTC to the local time of the computer but if the video wasn't shot at the same time as the computer, then it's more likely that such videos will need manual processing.

If you are using an exiftool version earlier than 13.12, then adding -api QuickTimeUTC will cause 0000 time stamps to show as 1903:12:31 or 1904:01:01, depending upon the local time zone
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

davidcpreston

You are correct; I was looking at the Windows File Properties, which shows no value for Date Created, just Media Created at 12:54, but if I look at the tags using EXIFTOOL I get:-
ExifTool Version Number         : 13.19
Create Date                     : 2025:02:16 15:34:04
Media Create Date               : 2025:02:16 15:34:04
Encoding Time                   : 2025:02:16 12:54:03+00:00

So, it did work, but as you said used UTC so would come last in sequence.
I tried adding the option, but it made no difference, or is that just for writing tags?
exiftool.exe" -fileorder CreateDate -api QuickTimeUTC "-filename<CreateDate" -m -d "%%Y %%B %%d %subtext% (%%%%-1C).%%%%e" *.*

Incidentally, I spent ages trying to get the %subtext% variable to work; I knew % had to be escaped so I tried %%subtext%%, then as an extra % is used in the date format I tried doubling up BUT I eventually tried it without escaping it and it worked, maybe as it's in quotes.
It's all interesting, and it's a great piece of work that Phil has done; this single line has replaced a long for loop with incrementing numbers etc.
 

StarGeek

Quote from: davidcpreston on February 16, 2025, 03:29:48 PMYou are correct; I was looking at the Windows File Properties, which shows no value for Date Created, just Media Created at 12:54

Windows is showing you Properties, not tags. Each Property may be filled by one or more actual tags. See the Windows Metadata thread to find out what tags will fill different Properties.

I'm trying to figure out the date/time from your posts. You say exiftool is showing 15:34, but Windows is showing 12:54. Something is off with that, as that would be a -02:40 time zone, which I don't think any country has.

Windows will read the CreateDate in a video and will automatically adjust it to local time when it displays the "Media created" time stamp.

QuoteI tried adding the option, but it made no difference, or is that just for writing tags?

No, the -api QuickTimeUTC will affect reading as well as writing.  Run this command
exiftool -time:all -G1 -a -s -api QuickTimeUTC file.mp4
This will show you all the date/time tags in the file and will adjust the UTC times to the local time.

For example, I set this file to noon today UTCC:\>exiftool -time:all --system:all -G1 -a -s Y:\!temp\Test4.mp4
[QuickTime]     CreateDate                      : 2024:02:16 12:00:00
[QuickTime]     ModifyDate                      : 2024:02:16 12:00:00
[Track1]        TrackCreateDate                 : 2024:02:16 12:00:00
[Track1]        TrackModifyDate                 : 2024:02:16 12:00:00
[Track1]        MediaCreateDate                 : 2024:02:16 12:00:00
[Track1]        MediaModifyDate                 : 2024:02:16 12:00:00
[Track2]        TrackCreateDate                 : 2024:02:16 12:00:00
[Track2]        TrackModifyDate                 : 2024:02:16 12:00:00
[Track2]        MediaCreateDate                 : 2024:02:16 12:00:00
[Track2]        MediaModifyDate                 : 2024:02:16 12:00:00

But when I add the -api QuickTimeUTC option, it's addjusted to my local time zone, -08:00. This will also be the value that Windows displays
C:\>exiftool -time:all --system:all -G1 -a -s -api QuickTimeUTC Y:\!temp\Test4.mp4
[QuickTime]     CreateDate                      : 2024:02:16 04:00:00-08:00
[QuickTime]     ModifyDate                      : 2024:02:16 04:00:00-08:00
[Track1]        TrackCreateDate                 : 2024:02:16 04:00:00-08:00
[Track1]        TrackModifyDate                 : 2024:02:16 04:00:00-08:00
[Track1]        MediaCreateDate                 : 2024:02:16 04:00:00-08:00
[Track1]        MediaModifyDate                 : 2024:02:16 04:00:00-08:00
[Track2]        TrackCreateDate                 : 2024:02:16 04:00:00-08:00
[Track2]        TrackModifyDate                 : 2024:02:16 04:00:00-08:00
[Track2]        MediaCreateDate                 : 2024:02:16 04:00:00-08:00
[Track2]        MediaModifyDate                 : 2024:02:16 04:00:00-08:00


QuoteIncidentally, I spent ages trying to get the %subtext% variable to work; I knew % had to be escaped so I tried %%subtext%%, then as an extra % is used in the date format I tried doubling up BUT I eventually tried it without escaping it and it worked, maybe as it's in quotes.

Since you're doubling the percent signs, I assume this is a Windows Bat file. Windows variables would not have doubled percent signs, as the doubling is needed to show the percent signs aren't variables.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

davidcpreston

What may be causing this is that the DJI drone they came from creates an MP4 file at high resolution and another of low resolution with an extension of LRF. I save frames as JPG from the high res, delete it, then rename the LRF to MP4 and save video clips if worthy of keeping, so it's probably that I saved the clip at 15:34, but assumed the Media Created that Windows shows is when it was actually taken. I'll take a video today and do a bit more investigation. Many thanks for your efforts.

Here is the exact command and results:-
"D:\Documents\Utilities\exiftool\exiftool.exe" -time:all --system:all -G1 -a -s "2025 February 16 Newcastle Quay & Ouseburn (8).MP4
[QuickTime]     CreateDate                      : 2025:02:16 15:34:04
[QuickTime]     ModifyDate                      : 2025:02:16 15:34:04
[Track1]        TrackCreateDate                 : 2025:02:16 15:34:04
[Track1]        TrackModifyDate                 : 2025:02:16 15:34:04
[Track1]        MediaCreateDate                 : 2025:02:16 15:34:04
[Track1]        MediaModifyDate                 : 2025:02:16 15:34:04
[Track2]        TrackCreateDate                 : 2025:02:16 15:34:04
[Track2]        TrackModifyDate                 : 2025:02:16 15:34:04
[Track2]        MediaCreateDate                 : 2025:02:16 15:34:04
[Track2]        MediaModifyDate                 : 2025:02:16 15:34:04
[Microsoft]     EncodingTime                    : 2025:02:16 12:54:03+00:00

Windows Explorer Properties show a blank creation date and a Media Created at 12.54

davidcpreston

Yep, my mistake, it was doing exactly what it should, even if it's not what I want.
I have a problem using -fileorder CreateDate with my JPGs captured from videos using Windows Photos as they all have the same Create Date, the start of the video. The filename assigned by Windows Photos is like "DJI_20250217100437_0001_D - frame at 2m15s.jpg", so I am using -fileorder FileName and this gets them in the correct order when they've been renamed. Apologies if I've wasted some of your time and many thanks for your efforts.