Applescript Date/Time File Renamer Folder Action

This is version 1.0 of the renameToDateTimeAndMoveToDateFolder Applescript Folder Action. I created it in order to rename photos taken using a Palm Zire 71, which doesn’t have very configurable file naming conventions for the photos taken. The Deyel photo gallery engine that I created in PHP reads jpg photos from directories named with the day that the photo was taken, and the file names must reflect the date/time stamp. So, I wrote this Folder Action to do the job of renaming them appropriately.

Place this applescript in the _root/Library/Scripts/Folder Action Scripts/ directory. Then apply it to a folder of your choice by command clicking on the folder and choosing Attach Folder Action (you must have folder actions enabled).

When the action has been applied to a folder, the script will take any files matching the extension list or the type list and rename them according to the creation date using the format “YYYYMMDDHHMMSS.EXT” and will place them in a folder (create it if necessary) for the day the file was created with the format “YYYY-MM-DD” inside the folder to which the action is applied.

This is handy for organizing digital photos, since most digital cameras give the photos non-meaningful names. This script does NOT use the jpeg EXIF metadata tag. The name is created using the creation date assigned to the file, which may or may not be passed to the file when syncing with the desktop machine. (This was originally created to rename photos synced from the Palm Zire 71). Use at your own risk.

Version 1.0 (Nov. 24, 2005)

Download :: renameToDateTimeAndMoveToDateFolder.zip

9 Comments

  1. ruby tuesday
    Posted July 30, 2007 at 2:45 am | Permalink

    thank you so much! i’ve been losing sleep over how to get exactly this done .. seems simple enough until i try to pull it off in applescript. i’m more of a C++ / Java person i guess. kudos to you

  2. Posted July 30, 2007 at 9:21 am | Permalink

    Cool. Good to know it helped. I’ll have to check and see what I’ve updated since then. And, yes, applescript is very verbose in some ways and somewhat counterintuitive at times. The best way to find out what syntax to use sometimes is just to find something similar that someone has done — it’s really hard to just find a reference guide online…

  3. Perroboy
    Posted September 9, 2007 at 4:47 am | Permalink

    Hi,
    Been searching for something like this for quite some time and was very excited to find yours.

    Thanks a mil!

  4. Perroboy
    Posted September 9, 2007 at 5:03 am | Permalink

    Sorry, but there’s one thing I don’t understand, and that’s the odd padding at the end of the filenames.

    For instance, an mpg created on 2003-12-02 is renamed: 20031202191812.mpg.

    What’s 191812? The precise timestamp? Can I truncate this somehow?

    Sadly, still doesn’t give me a workaround for files created on my videocam, which frequently dies and experiences date reset, producing files taken 1904-01-01 :(

  5. ii auai
    Posted December 31, 2008 at 2:57 am | Permalink

    i kinda gutted this for a different use, but it hit the spot as a good starting point to 90% of my problem, all these years later. thanks!

  6. Posted January 12, 2009 at 3:14 pm | Permalink

    Cool! Good to know it helped. :-)

    I might also recommend a open-source project called jhead, which I found recently. Jhead is exceedingly helpful as well for doing things related to the EXIF data in jpgs.

  7. el loco
    Posted February 11, 2009 at 12:36 pm | Permalink

    great ! easy n clean ! thanks

  8. Jacob Wegelin
    Posted August 2, 2009 at 9:22 am | Permalink

    Thank you. Along with http://run-amuck.com/blog/2009/02/mac-os-x-screen-capture-default-location-and-default-file-name/, this worked.

    Any suggestions how I would automatically perform a *subset* of this, i.e.: every time I copy or move a file to the designated folder, the file is renamed to the date and time, as the screen capture files are renamed by your script?

    Better yet, instead of being renamed purely to the date and time, the date and time are pre-pended to the current filename? So that when I move “dog.txt” to the designated directory, it turns into 2009080212200115-dog.txt?

    Another modification: Is there a way to get rid of the subdirectory for each day, so that all the files go into the designated directory? Since the filename starts with the date, there should be no confusion of files anyway, no real need of the many subdirectories.

    Thanks for any suggestions.

  9. Posted September 15, 2009 at 6:05 am | Permalink

    Thanks for this extremely useful conversion tool. Hard to believe it’s not built into AppleSCript.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*