rename mp4 and thm files (same name)

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

rename mp4 and thm files (same name) Sun Jan 27, 2013 3:19 am • by tia
Hi
I have the following problem:
When I import videos from my camera I get to each mp4 file each another thm file. This includes the exif data of the video file. The name of the two files are exactly the same only the ending is different.
Now I want to rename these files:

before:
MAH0001.thm
MAH0001.mp4

after:
2012-01-27_08-20-42.thm
2012-01-27_08-20-42.mp4

Source for this date and time will be the exif-Recorded from the thm file.

How can I do that?

tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Sun Jan 27, 2013 11:55 am • by a_freyer
Have you checked to make sure that the date created of each of these files does not match the date that you're looking for within the thm?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: rename mp4 and thm files (same name) Sun Jan 27, 2013 3:34 pm • by tia
Creation date, and modification date of the thm file and the mp4 file are unfortunately shifted by a few seconds. :(

tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Sun Jan 27, 2013 3:39 pm • by a_freyer
And I suppose that those seconds matter, eh? :-)

Can you post a plaintext of the thm file?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: rename mp4 and thm files (same name) Sun Jan 27, 2013 5:10 pm • by tia
yes ...

The following are the first lines of a thm file:

------
ˇÿˇ·¸ExifII*
 ܶ¨¥º(2ƒiáÿ SONYNEX-5N^^2013:01:19 07:01:23 ê0230êbêvëëäÜí@í†0100††††x†“2013:01:19 07:01:232013:01:19 07:01:23THM0100ˇ€Ñ
------

I also tried the applescript from the following post but that does not somehow ...

viewtopic.php?f=4&t=1199



tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 1:40 am • by tia
Finally, the two files (mp4 and thm) get after renaming the same name. As the source of the name is also the creation date or modification date serve. It need not necessarily be the recording date of the exif data.

2012-01-27_08-20-42.thm
2012-01-27_08-20-42.mp4


tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 12:19 pm • by a_freyer
Doesn't the EXIF merely contain the creation date of the MP4 itself?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 1:08 pm • by tia
Can I give two files the same name with Hazel? (the suffix maintained)

or

How should I use the following applescript



Code: Select all
set AppleScript's text item delimiters to ":"
set theParentDir to (text items 1 through -2 of (theFile as string)) as string
set theFileName to (text item -1 of (theFile as string)) as string

set AppleScript's text item delimiters to "."
set theExtension to the last text item of theFileName
set theBasename to (text items 1 through -2 of theFileName) as string

set theNewFile to theParentDir & theBasename & ".m4v"

set AppleScript's text item delimiters to ""

return {hazelSwitchFile:theNewFile}



Source:
viewtopic.php?f=4&t=1199

tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 1:13 pm • by a_freyer
Look, first things first. The script you've posted is not particularly helpful unless we know what kind of data you are looking to get.

Yes, you can name any number of files the same in Hazel, but you have to be clever about it and it involves a bit of scripting. However, it is very simple scripting.

That said... can you answer which date SPECIFICALLY you are looking for?

Movie.mp4 will have creation date, modification date, access date, etc. accessible within its own metadata.
Movie.thm will have creation date, modification date, access date, etc. accessible within its own metadata, and within its content it will contain info about Movie.mp4.

Which date are you specifically looking to rename these files with?
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 1:22 pm • by tia
Hello

the modification date of the mp4 file


tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 1:24 pm • by tia
or the date that corresponds to the recording date

tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 1:49 pm • by a_freyer
I just tested this, and it works:

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     extension is mp4
     name matches MAH(123)

Do the following to the matched file or folder:
     rename with pattern (name);(date modified)(extension)
     run shell script (embedded script)


The DATE MODIFIED portion is formatted (ignore the JPG in this screenshot, I was testing with a jpg):

The embedded script is this:

Code: Select all
NAME=$(echo "$(basename "$1")" | awk -F '[;.]' '{print $1}')
MOD_DATE_FORMATTED=$(echo "$(basename "$1")" | awk -F '[;.]' '{print $2}')

mv "$(dirname "$1")/$NAME.thm" "$(dirname "$1")/$MOD_DATE_FORMATTED.thm"

mv "$1" "$(dirname "$1")/$MOD_DATE_FORMATTED.mp4"


EDIT - added the MAH as a prefix
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: rename mp4 and thm files (same name) Mon Jan 28, 2013 5:03 pm • by Mr_Noodle
I believe the problem is that Apple's Spotlight importer does not map EXIF's "date taken" to anything. It seems they could have easily mapped it to the content creation date but they didn't and still haven't fixed it after all these years.

You can try and look for a commandline program which will parse EXIF data and incorporate that into Hazel or, though I haven't heard of such a thing, see if someone's written a replacement Spotlight importer.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: rename mp4 and thm files (same name) Tue Jan 29, 2013 2:17 am • by tia
@ a_freyer


You are awesome!

It works fine!

big thanks


tia
tia
 
Posts: 12
Joined: Sun Jan 27, 2013 2:02 am

Re: rename mp4 and thm files (same name) Tue Jan 29, 2013 12:46 pm • by a_freyer
Great to hear! Happy organizing!
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado


Return to Support