ExifTool Forum

General => Metadata => Topic started by: wildcowboy on November 07, 2016, 11:51:12 AM

Title: Finding files with similar name struture
Post by: wildcowboy on November 07, 2016, 11:51:12 AM
Hello,
I have many files named like this in multiple directories:

filename.mp4
filename_postfix.mp4

Example:
20141121_173844203_iOS_x264.mp4
20141121_173803377_iOS_x264_6500kbps.mp4

and looking for a way to find all files filename.mp4 and copy tags and some dates from them to files filename_postfix.mp4

I do know the actual commands to copy tags etc. but I am not sure if I could make exiftool find files the way I need.

Please let me know if you have any ideas.
Title: Re: Finding
Post by: StarGeek on November 07, 2016, 12:07:22 PM
Nevermind (http://imgur.com/RA6fITc.jpg)

You'll want to look into learning Regular Expressions (RegEx).  You can use them with the -if option to filter just about any combination of characters.  But it's not very easy to learn.  I used this site (http://www.regular-expressions.info/) to learn them and RegEx101 (https://regex101.com/) to test them out.

Going off your example, you could try something like this:
exiftool -if "$filename=~/\d{8}_\d{9}_.*?_.*?\." "-filename<$filename_$OtherTags" DIR

I'm making the assumption that your filename is always 8 digits, underscore, 9 digits, underscore, some group of characters, underscore, some group of characters, and then a dot, while ignoring the extension.  This can fail if there's an underscore in either of the "Group of characters". 

Further refinements can be made with other examples where this code doesn't work.
Title: Re: Finding
Post by: Phil Harvey on November 07, 2016, 12:44:23 PM
@StarGeek: I think the problem is to copy tags from one file to the other, not rename the file.

This is tricky.

Is either the length of the file name or the length of the postfix always constant?

Also note that ExifTool has only limited ability for writing MP4 files.  Are you sure it will write what you want?

- Phil
Title: Re: Finding
Post by: StarGeek on November 07, 2016, 12:45:43 PM
Quote from: Phil Harvey on November 07, 2016, 12:44:23 PM
StarGeek: I think the problem is to copy tags from one file to the other, not rename the file.

Yep, you're right.  My reading comprehension has been all off these days.
Title: Re: Finding
Post by: wildcowboy on November 07, 2016, 01:15:33 PM
Quote from: Phil Harvey on November 07, 2016, 12:44:23 PM
@StarGeek: I think the problem is to copy tags from one file to the other, not rename the file.

This is tricky.

Is either the length of the file name or the length of the postfix always constant?

Also note that ExifTool has only limited ability for writing MP4 files.  Are you sure it will write what you want?

- Phil

The length of the file name and the length of the postfix seem to be always constant for the majority of the files.
I just went through the files quickly and did not notice many tags there. What I did notice is that "Media created" date is missing for the files with postfix.
Media created per Windows file properties) is DatePictureTaken per exiftool.
I do see that ContentCreateDate remains untouched though.
I should investigate if I need that DatePictureTaken info for my use at all.
Title: Re: Finding
Post by: wildcowboy on November 07, 2016, 02:51:48 PM
I was able to find any tool that can modify DatePictureTaken of an mp4 file other than Windows Live Photo Gallery.
Neither exiftool nor ffmpeg can do that.
Do you know if there is one?
Title: Re: Finding files with similar name struture
Post by: wildcowboy on November 07, 2016, 03:25:59 PM
Update: DatePictureTaken (ExifTool) of an mp4 file is not "Media Created" (Windows file properties)
I am not sure what Tag ID the "Media created" is but looks like there is almost no tool to modify it anyways so I decided to bail on it for now