set creation date of .mov to file name

Discussion in 'Mac Apps and Mac App Store' started by bjriffel, Aug 13, 2013.

  1. bjriffel macrumors newbie

    Joined:
    Feb 15, 2009
    #1
    Normally people are doing this in reverse, but let me paint the picture.

    I pulled 204 video files from an old HDD based JVC camera. JVC records in .MOD format which iPhoto won't import. I imported them into iMovie just fine, and iMovie even set the file name to clip-2007-11-04 04;42;29.mov which is great, but it now has a new creation date of whatever date I imported it. Which then causes problem when I want the videos stored in iPhoto and sorted appropriately by creation date.

    I've used the application "A Better Finder Attributes 5" to individually edit the creation and modify, but I'm sure I don't want to do this 203 more times, as you can't just type in the date and time, you have to type in each part of the date/time, or select it on a calendar.

    I've used the application "Name Changer" to batch convert the file names to the format YYYYMMDDhhmm which would be helpful if I were going to use the terminal command touch -t, but again I don't want to have to type it in 203 more times, plus drag and drop the file into finder to populate the location.

    Now, if I were more handy with automator, or maybe some (any) scripting language this would be easy peasy. I'd batch rename all the files to the YYYYMMDDhhmm.mov and then have a script that just took the file name, passed that to touch -t along with the file location, and a few seconds later, they would all be done!

    Anybody have any suggestions to how I can do this, and tips to what commands to use or ANY advice? I'm more than happy to RTFM, but I have no idea which manual to read!

    Thanks
     
  2. jamietshaw macrumors member

    Joined:
    Sep 25, 2009
    Location:
    UK
    #2
    Not a full reply but hopefully this will help.

    Firstly, to create a script that loops round some files make a file containing this:
    Code:
    #!/bin/bash
    
    for f in "$@"
    do
            echo "f is: $f"
    done
    then:

    Code:
    chmod +x yourfile
    ./yourfile /path/to/files/*
    …will list the files. Not useful in itself, but now you know that $f in the script stores the filename.

    As for then getting the relevant bits out of the filename (i.e. $f), maybe http://stackoverflow.com/questions/10586153/bash-split-string-into-array will help.

    A lower-tech approach could be:
    • Copy and paste the files from the Finder to a text editor such as TextWrangler (so you have a list of all the files)
    • Find and replace the characters that separate the information (hyphens, spaces, semicolons) with a comma.
    • Save the file as .csv then open in Excel so each bit of information is now in columns.
    • Paste in the original filenames too
    • In an empty column do a formula to join together the bits you want in the right order and with the touch command at the beginning and the full filename at the end, e.g. ="touch -t "&A2&A3&A4&" "& ""A5""
    • Paste this new column, which is now a series of valid commands, into a text file, save, make executable (i.e. chmod +x again) and run
     

Share This Page