Hi
I have literally thousands of media files to rename with date time of recording start & stop information from their EXIF sidecar files [as per 'shot date' in the Dynamic Media section of exif data]
I am hoping you could help me with two solutions I need that maybe EXIFTOOL can provide.
My file naming convention is...
01 - Year / Month / Day
02 - Separator - '2 spaces'
03 - 'Recording Start' time with double digit Hour in 24 hr mode, dash, Minute, space, Second
04 - Separator - 'space, dash, space'
05 - 'Recording Stop' time with double digit Hour in 24 hr mode, dash, Minute, space, Second
06 - Separator - 'space, dash, space'
07 - Original File name
so a file named
"HD 001"
That started recording on Dec 1, 2008 at 12-45 am and lasted 1 hr, 2 minutes & 10 seconds
would become
"2008-12-01 00-45 15 - 01-47 25 - HD 001"
A / What action / script would I need to run to perform this in Exiftool.
B / Also, as some files have inaccurate times due to wrong camera settings I would appreciate a 'post rename as above' method of fixing them, ie for files that might be 1 day 2hrs, 5 mins 10 seconds out, what would I need to apply to add or subtract this difference from the filename as created above.
A step by step for dummies guide would be appreciated to perform these operations on files [and their exif sidecars] in selected folders
Any help would be much appreciated
Zakk
Presumably the EXIF files also store the XMP dynamic media Duration. Then the command will be something like this (assuming the EXIF files are named the same as the videos, and have a ".exif" extension):
exiftool -tagsfromfile %d%f.exif "-testname<${ShotDate} - ${ShotDate#;ShiftTime('0:0:'.$self->GetValue('Duration','ValueConv'));DateFmt('%H-%M %S')} - $filename" -d "%Y-%m-%d %H-%M %S" DIR
If you are on Mac or Linux, swap all double quotes (") and single quotes (').
Once you are happy with the output of this file, replace testname with filename to actually rename the files.
This command is a bit tricky because it uses the -tagsfromfile advanced formatting feature (https://exiftool.org/exiftool_pod.html#Advanced-formatting-feature) to shift ShotDate and apply a different formatting for the recording stop time.
See this page (https://exiftool.org/filename.html) for more details about how the file renaming feature works, including a list of the date/time formatting codes.
- Phil
Hi Phil
cheers for quick reply
The sidecar files are named as the media files but the extension is XMP, not exif - I just think of their description as exif, sorry
I would need the detailed .how to. steps to apply your solution as I have not idea how to apply it to the file or folder with the files I want to process
I mean do I enter it at the command line ?
how to I specify folder and what files to process as a batch within the folder.
Also stuff like duration appears to be contained in the adobe PROJECT metadata, not the XMP
Opening the XMP data I can only identify 'shotdate' and start timecode in 'Timevalue'
I include the data from a files XMP below in case you can see something I don't.
If the recording stop time can't be derived in any way from the XMP I could live without that if I have to.
The start time is the most important
So I would be happy with a result......
01 - Year-Month-Day
02 - Separator - '2 spaces'
03 - 'Recording Start' time with double digit Hour in 24 hr mode, dash, Minute, space, Second
04 - Separator - 'space, dash, space'
05 - Original File name
resulting in
"2008-12-01 00-45 15 - HD 001"
so its simply a matter of reformatting the 'shot date' data line and placing it in front of the original filename
Ultimately, the most important thing to me is that my files appear in start time derived chronological order
Using my real file "HD 151 - 99", with a duration of 23 seconds 13 frames, as an example
It's XMP file has the following data:
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-c060 61.133984, 2009/12/08-18:06:32 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
xmlns:xmpDM="http://ns.adobe.com/xmp/1.0/DynamicMedia/"
xmlns:stDim="http://ns.adobe.com/xap/1.0/sType/Dimensions#"
xmpMM:InstanceID="xmp.iid:8C699563FCA5DF11B4BCF35233739390"
xmpMM:DocumentID="xmp.did:8A699563FCA5DF11B4BCF35233739390"
xmpMM:OriginalDocumentID="xmp.did:8A699563FCA5DF11B4BCF35233739390"
xmp:MetadataDate="2010-08-12T22:28:56+12:00"
xmpDM:videoFrameRate="25.000000"
xmpDM:altTapeName="HD 151"
xmpDM:shotDate="2008-10-25T01:55:45"
xmpDM:audioCompressor="Uncompressed"
xmpDM:videoPixelAspectRatio="4/3"
xmpDM:videoFieldOrder="Upper"
xmpDM:videoAlphaMode="none"
xmpDM:audioSampleRate="48000"
xmpDM:audioSampleType="Compressed"
xmpDM:audioChannelType="Stereo"
xmpDM:startTimeScale="25"
xmpDM:startTimeSampleSize="1"
xmpDM:tapeName="HD 151"
xmpDM:logComment="">
<xmpMM:History>
<rdf:Seq>
<rdf:li
stEvt:action="saved"
stEvt:instanceID="xmp.iid:8B699563FCA5DF11B4BCF35233739390"
stEvt:when="2010-08-12T22:28:46+12:00"
stEvt:softwareAgent="Adobe Premiere Pro 5.0"
stEvt:changed="/metadata"/>
<rdf:li
stEvt:action="saved"
stEvt:instanceID="xmp.iid:8C699563FCA5DF11B4BCF35233739390"
stEvt:when="2010-08-12T22:28:56+12:00"
stEvt:softwareAgent="Adobe Premiere Pro 5.0"
stEvt:changed="/metadata"/>
</rdf:Seq>
</xmpMM:History>
<xmpDM:videoFrameSize
stDim:w="1440"
stDim:h="1080"
stDim:unit="pixel"/>
<xmpDM:startTimecode
xmpDM:timeValue="00:05:22:11"/>
<xmpDM:altTimecode
xmpDM:timeValue="00:05:22:11"/>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
PH Edit: Removed blank lines and put XMP in code block
Hi Zakk,
For details on how to run this, I need to know what system you are using. eg. Windows, Mac or Linux?
If the video duration is not available in the metadata, then the end time can't be determined and the command gets much simpler:
exiftool -tagsfromfile %d%f.xmp "-testname<$ShotDate - $filename" -d "%Y-%m-%d %H-%M %S" DIR
You enter this at the command line, but instead of typing "DIR", drag and drop the folder of the files that you want to rename.
- Phil
Wow Phil,
you are the quickest responder I have ever encountered
I hope your people appreciate your efforts
My system is Win 10 64 bit PC, AMD, brand new build
Using an online metadata reader I found the video duration is available in the metadata of the video file itself, not the XMP
For the file example I quoted the relevant metadata is....
Duration
24.08 s
so if the original format I asked about with recording stop time can be created that would be awesome
re procedure
I open command prompt
enter the line of code you gave without the DIR at the end
then drag n drop a file or folder... onto the command line window?
If so - that's simple
Yup. That's the procedure. Then press RETURN after dropping the file/folder.
For both the start and stop time to be added to the file name in a single command, both of these must be available from a single file (either the video or the xmp file). Video files typically have a CreateDate you can use. You can see the available date/time tags with this command:
exiftool -time:all -a -G1 -s FILE
(drag and drop the video file instead of typing "FILE")
If CreateDate and Duration are both extracted for the video, you can use this command:
exiftool "-testname<${CreateDate} - ${CreateDate#;ShiftTime('0:0:'.$self->GetValue('Duration','ValueConv'));DateFmt('%H-%M %S')} - $filename" -d "%Y-%m-%d %H-%M %S" DIR
- Phil
BTW, my first response would have been a lot faster except that we had a fire alarm here and I had to vacate the building to go stand outside in -21 C weather for 20 minutes. :P
using 'command prompt & entering your code line
I get
'exiftool' is not recognized as an internal or external command,
operable program or batch file.
Either install exiftool for command-line use by following these instructions (https://exiftool.org/install.html#Windows), or drag and drop "exiftool(-k).exe" onto the command window instead of typing "exiftool".
- Phil
the time extraction code you gave only returned the creation and modified from digitiising date not the shot dat from the XMP
I tested the line you gave
dropping the exiftool exe onto command
inserting the code line you gave then drop the file and got this
C:\Users\zrokk>"K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\exiftool(-k).exe""-testname<${CreateDate} - ${CreateDate#;ShiftTime('0:0:'.$self->GetValue('Duration','ValueConv'));DateFmt('%H-%M %S')} - $filename" -d "%Y-%m-%d %H-%M %S""K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\HD 151 - 99.mpeg"
The filename, directory name, or volume label syntax is incorrect.
C:\Users\zrokk>
I've got something wrong
The XMP only has only shot date not duration
the file metadata has the duration but not shot date - only date from date the file digitized
You need to put a space before/after dropping a file on the command window.
If you must use ShotDate, then you give up the ability to add the end time in one command. And it would take some work to add this afterward. So the command would be:
exiftool -tagsfromfile %d%f.xmp "-testname<$ShotDate - $filename" -d "%Y-%m-%d %H-%M %S" DIR
- Phil
Hi
Shotdate is the only option so start date & Time is only result possible -all good
I'm doing something wrong
01 - I hit return to get back to command prompt
02 - add space
03 - drop exiftool9-k0.exe onto command line
04 - add space
05 - paste exiftool -tagsfromfile %d%f.xmp "-testname<$ShotDate - $filename" -d "%Y-%m-%d %H-%M %S"
06 - add space
07 - drop media file
08 - add space
09 - Hit return
result is
C:\Users\zrokk> "K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\exiftool(-k).exe" exiftool -tagsfromfile %d%f.xmp "-testname<$ShotDate - $filename" -d "%Y-%m-%d %H-%M %S" "K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\HD 151 - 99.mpeg"
Warning: Error opening file - exiftool.xmp
Error: File not found - exiftool
'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/exiftool-11.80/HD 151 - 99.mpeg' --> 'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/exiftool-11.80/2008-10-25 01-55 45 - HD 151 - 99.xmp'
0 image files updated
1 image files unchanged
1 files weren't updated due to errors
-- press RETURN --
That worked. Just drop the extra " exiftool " that you pasted to avoid some of the error messages. This line shows what the file would be renamed to:
'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/exiftool-11.80/HD 151 - 99.mpeg' --> 'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/exiftool-11.80/2008-10-25 01-55 45 - HD 151 - 99.xmp'
So the new file name would be "2008-10-25 01-55 45 - HD 151 - 99.xmp".
So the only problem is that my command would change the ".mpeg" extension to ".xmp'. Paste this in instead to fix this:
-tagsfromfile %d%f.xmp "-testname<$ShotDate - %f.%e" -d "%Y-%m-%d %H-%M %S"
Note that if you run it on a whole directory, you will need to add -ext mpeg to process .mpeg files since they are not normally writable (see FAQ 16 (https://exiftool.org/faq.html#Q16)). Also add -ext xmp to rename the XMP sidecar files too.
- Phil
Hi Phil
This is all new to me & confusing
Can you give me a step by step process to follow with the exact line of code to paste without me having to change anything
ie
01 - Hit return
02 - etc....
I'm just not familiar with command line use
It might be easier for me to have an exact line of code to paste in that includes both the path to the exif exe and the code to process the file
so all I would have to do is...
01 - paste in the code at the command prompt
02 - then drop in the file or folder of files
03 - and then hit enter [or whatever to launch the process]
That would mean all I have to do is pate the code and drop the file / folder to do this.
The path to the exif app is....
K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\exiftool(-k).exe
OK. Paste this:
"K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\exiftool(-k).exe" -tagsfromfile %d%f.xmp "-testname<$ShotDate - %f.%e" -d "%Y-%m-%d %H-%M %S" -ext mpeg -ext xmp
Then press SPACE then drag and drop the folder, then press RETURN.
- Phil
Even easier: Download the attached .bat file and drop the folder onto the rokko.bat file icon (no command window needed).
- Phil
might be getting closer, love the Bat idea
however something still not right
dropped the file on the Bat & got this
K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80>"K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\exiftool(-k).exe" -tagsfromfile %d%f.xmp "-testname<$ShotDate - %f.%e" -d "%Y-%m-%d  %H-%M %S" -ext mpeg -ext xmp "K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\HD 151 - 99.mpeg"
'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/exiftool-11.80/HD 151 - 99.mpeg' --> 'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/exiftool-11.80/2008-10-25-ß 01-55 45 - HD 151 - 99.mpeg'
Warning: FileName encoding not specified - K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/exiftool-11.80/HD 151 - 99.mpeg
0 image files updated
1 image files unchanged
-- press RETURN --
The only problem is that one of the spaces in my .bat file was a non-breaking space instead of an ASCII space, which is why you got the warning and the funny character in the file name. I have fixed the attached file in my previous post. Re-download the new version.
But other than that, it worked perfectly. Nothing was changed because the .bat file is writing the "testname" tag instead of "filename". Change this in the .bat file to actually rename the file.
- Phil
redownloaded the updated bat file from previous post
dropped a folder with test file and it's xmp onto it
got this in command window
K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool>"K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\exiftool-11.80\exiftool(-k).exe" -tagsfromfile %d%f.xmp "-testname<$ShotDate - %f.%e" -d "%Y-%m-%d %H-%M %S" -ext mpeg -ext xmp "K:\300 - Applications Avatar\000 - Core 2 - Basic Utilities\UTIL - RENAME - EXIF - Exiftool\Test files"
'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/Test files/HD 151 - 99.mpeg' --> 'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/Test files/2008-10-25 01-55 45 - HD 151 - 99.mpeg'
'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/Test files/HD 151 - 99.xmp' --> 'K:/300 - Applications Avatar/000 - Core 2 - Basic Utilities/UTIL - RENAME - EXIF - Exiftool/Test files/2008-10-25 01-55 45 - HD 151 - 99.xmp'
1 directories scanned
0 image files updated
2 image files unchanged
-- press RETURN --
The filenames were unchanged
The files are
HD 151 - 99.mpeg
HD 151 - 99.xmp
We're getting closer, I am sure and I seriously appreciate your time with this
Quote from: Phil Harvey on December 19, 2019, 01:03:46 PM
Nothing was changed because the .bat file is writing the "testname" tag instead of "filename". Change this in the .bat file to actually rename the file.
Looking at the response from the command line
It appears to be working perfectly as the new filename is perfect in the readout
its simply not renaming the actual files themselves
I have no idea how to change anything in the bat file
The .bat file is a plain text file. You can edit it with any plain text editor. But I have done it for you. See the attached file.
- Phil
Cheers Phil
It works perfectly now - the two bats are great as I can test then run the real rename
I had tried to open the bat in my notepad but the 'open with' option wasn't there in my Q-Dir browser
Anycase..
thank you so much for your personal time in perfecting this for me
Thanks to you I now have the means to update all these thousands of media files and access them in chronological order.
Very very much appreciated
and thank you so much for taking the time to help a stranger.
Its rare to encounter and such a breath of fresh air.
I hope you have an awesome Xmas and a fantastic new year
thanks again
Zakk