Create Tags from Filename

Started by mpierce, November 24, 2021, 07:40:49 PM

Previous topic - Next topic

mpierce

I have a bunch of old home movies that have been converted to MP4.  We are wanting to watch these though Plex and have found they aren't tagged correctly to have the titles show up and sort by year.  I have found that if I modify the Title tag in windows explorer to what I want it to say along with the Year tag Plex will handle the files as desired.

The files are currently named like the following:

1998 - Christmas at Home.mp4

I'm looking for a way to pull the year from the filename and update the Year tag to match as well as create a title tag from the rest of the filename.

Thanks in advance for the guidance!

StarGeek

Try
exiftool "-Year<{$Filename;s/^(\d{4}).*/$1/}" "-Title<${Filename;s/^\d{4} - //}" /path/to/files/
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mpierce

Thanks for the quick response.

That worked to change the Title tag.  It did also copy the .mp4 extension is there a way to remove that from the title?

It gave an error for the Year tag and didn't update it.

Here is the output from the command:

D:\test>exiftool "-Year<{$Filename;s/^(\d{4}).*/$1/}" "-Title<${Filename;s/^\d{4} - //}" .
Warning: [minor] Tag '1' not defined - ./1979 - Jun Monte & Juile Wedding Day.mp4
Warning: [minor] Tag '1' not defined - ./1984 - Dec Christensen House.mp4
Warning: [minor] Tag '1' not defined - ./1984 - Dec Christmas Christensen Grandma Swenson.mp4
    1 directories scanned
    3 image files updated

StarGeek

For the Title, change Filename to Basename and make sure you have a fairly recent version of exiftool.

For the year, a typo on my part. The brace should be after the dollar sign.  It should be
"-Year<${Filename;s/^(\d{4}).*/$1/}"
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mpierce

That fixed the error and got rid of the .mp4 extension.

The Year tag is updating when I run exiftool against the file:

Year                            : 2004
XMP Toolkit                : Image::ExifTool 12.36
Title                           : Spanish Music Video

But when I view the properties in windows explorer it's still showing 2021 (see attachment).  Is there another tag I should be using?




StarGeek

Ah, yes.  See this post.  You have to scroll down to get to the MP4 section, but Windows Year property reads the ContentCreateDate.  I don't believe that tag name is used anywhere else, so you don't need to prefix it with Quicktime or ItemList.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

mpierce

I got it to work.  Here is the final command I am using. 

exiftool "-ItemList:ContentCreateDate<${Filename;s/^(\d{4}).*/$1/}:01:01 01:01:01" "-Title<${Basename;s/^\d{4} - //}" -overwrite_original .

I needed to add the date and time to the ContentCreateDate to make it work correctly.  Since all I really cared about was the year I just set it to Jan 1st.

Thanks for the help its much appreciated!!