ExifTool Forum

ExifTool => Newbies => Topic started by: mpierce on November 24, 2021, 07:40:49 PM

Title: Create Tags from Filename
Post by: mpierce on November 24, 2021, 07:40:49 PM
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!
Title: Re: Create Tags from Filename
Post by: StarGeek on November 24, 2021, 08:49:37 PM
Try
exiftool "-Year<{$Filename;s/^(\d{4}).*/$1/}" "-Title<${Filename;s/^\d{4} - //}" /path/to/files/
Title: Re: Create Tags from Filename
Post by: mpierce on November 24, 2021, 10:38:38 PM
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
Title: Re: Create Tags from Filename
Post by: StarGeek on November 25, 2021, 12:19:35 AM
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/}"
Title: Re: Create Tags from Filename
Post by: mpierce on November 25, 2021, 01:10:55 AM
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?



Title: Re: Create Tags from Filename
Post by: StarGeek on November 25, 2021, 01:58:53 AM
Ah, yes.  See this post (https://exiftool.org/forum/index.php?topic=6591.msg32875#msg32875).  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.
Title: Re: Create Tags from Filename
Post by: mpierce on November 25, 2021, 01:03:20 PM
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!!