Previous 1 2 3 4 5 Next 61 Replies Latest reply: Apr 19, 2015 5:43 AM by pointvicente Go to original post
  • Mike Maas Level 1 Level 1 (0 points)

    The system I use is a folder for each year then subfolders for the full creation dates under the year folder.  The files are then stored in the subfolder of the date the file was created.  I can get it to create both a year folder and a creation date folder but the creation date folder is another folder in the The Container not as a subfolder of the year folder.  How can I get it to work?

  • red_menace Level 6 Level 6 (14,905 points)

    You just need to insert another folder creation step, for example:

      ...     if theClass is document file then try -- just documents       set theDate to text 1 thru 10 of (creation date of anItem as «class isot» as string) -- YYYY-MM-DD       set theYear to text 1 thru 4 of theDate       try -- check if the year folder exists         get ("" & theContainer & theYear) as alias       on error -- make a new year folder         make new folder at theContainer with properties {name:theYear}       end try       set yearFolder to the result                  try -- check if the date folder in the year folder exists         get ("" & yearFolder & theDate) as alias       on error -- make a new date folder         make new folder at yearFolder with properties {name:theDate}       end try       -- duplicate anItem to the result       move anItem to the result   ...

  • Mike Maas Level 1 Level 1 (0 points)

    Thanks, it works great.

  • Mike Maas Level 1 Level 1 (0 points)

    Thanks,

     

    I am trying to get it to work where I can just drop a folder with the file I want sorted and move into the application icon for Automator application, and it does its thing.  I made the first Automator action Get Folder Contents (removing the Get Folder Contents) and made the first line of the script "on run".  got a message "The action “Run AppleScript” encountered an error.  Check the actionʼs properties and try running the workflow again."

     

    Being an applescript novice I an lost.  Can you help? Thanks

  • red_menace Level 6 Level 6 (14,905 points)

    You don't need to add another "on run" - the posted script (with the previous modification) is all you need to place into the Run AppleScript action, replacing its default script.  Saving the workflow as an application will allow you to use it as a droplet (items dropped onto the application will be passed to the workflow), so you don't need other actions in order to get items.  When using your workflow like that, all you need to add is a Get Folder Contents action to get files from any folders dropped, and possibly a Filter Finder items action if you want to filter the types of files passed on.

     

    The workflow can still be run from Automator, in that case you just need to temporarily add another action at the beginnning to get some input items.  Automator has a log at the bottom of the workflow section - clicking on the error should expand it to tell you what the specific error is, instead of the generic "encountered an error" message.

  • hotsaucedaily Level 1 Level 1 (0 points)

    This thread is about one of the most searched for tasks.

     

    I've read thru the entire 4 pages of the post from 2009 to today.

     

    As a newcomer to the thread, it is disjointed and confusing.

     

    Someone should post the step-by-step process to perform this most basic of tasks/requests, from start to finish.

     

    A video would be gold!

     

    I gotta tell ya, I'm ok playing with Automator, but when it comes to Applescript AND Automator... I'm lost.

     

    As the title of the post says: "Relocating files based on creation date" - at this point all we need is a good tutorial of the steps needed to accomplish this.

     

    Let's wrap this up with the ultimate step-by-step instruction, for us novices as well as experts wanting to save some time.

     

    Thanks in advance!

     

    ~brian

  • red_menace Level 6 Level 6 (14,905 points)

    Yes, and this is the main reason for people to start a new topic (referring to a related one if needed), but it doesn't usually happen that way.  Setting the forum view preferences to threaded should help organize various threads, but that also doesn't work very well if people reply to the wrong person or the original post.

     

    Some of the formatting got lost when the forums were updated, so some of those old replies include some HTML which the AppleScript Editor will not like, but the answer would appear to be my first reply back in 2009 (although the OP didn't mark any reply as helpful or the answer).  Pretty much everything else is a "hey, it's close, but I want it to do this" kind of thing, so those threads contain the modifications for that kind of thing.

     

    The Run AppleScript action is what does all of the work, and replaces the default script - the rest of the workflow just gets the files to pass on to it, so the workflow is just something like:

     

    1. Ask for FInder Items {Type: Folders} -- can also get files
    2. Get Folder Contents (be careful with getting subfolders - this action will go into packages)
    3. Run AppleScript -- paste in the original script (minus the HTML) or the various tweaks posted
  • hotsaucedaily Level 1 Level 1 (0 points)

    @red_menace - I get what you are saying about topics, threads, the formatting from the old forums, etc.

     

    You obviously are very well versed in this topic, and have been hugely helpful to many people. But I'm afraid, in your knowledge, you miss my point. I need hand-holding from Point A to Point Z. IOW, a simple, step-by-step set of instructions to get the job done. Without having to sort thru 5 years of posts in one thread.

     

    Pretend this is the very first post, and share your answer that I and others can understand.

     

    1. Run AppleScript -- paste in the original script (minus the HTML) or the various tweaks posted

    That is just what I don't need. No offense, but it just adds to my confusion. "Various tweaks"? That's great for other options that some may need, but to stick to the original topic, some of us are just looking for a way to "relocate files based on creation date".

     

    Hopefully someone in this thread (you?) will just post a simple tutorial in its entirety.

     

    Again, thanks for your help.

  • Mike9586 Level 1 Level 1 (0 points)

    Thanks so much this script has really helped me. However is it possible to get the script to create folders based on the name YYYY_MM_DD rather than YYYY-MM-DD? The only reason is my old camera software on my Windows PC did it this way so it would make things a lot neater if all the folders were the same naming style on my external hard drive.

     

    Thanks so much once again.

  • red_menace Level 6 Level 6 (14,905 points)

    The name is just the first 10 characters of an ISO date/time string, which is in the format YYYY-MM-DDThh:mm:ss

    set theDate to text 1 thru 10 of (creation date of anItem as «class isot» as string)

     

    So you can replace that statement with something else to tear the date string apart and rearrange it however you want, for example:

    tell (creation date of anItem as «class isot» as string)
      set theDate to text 1 thru 4 & "_" & text 6 thru 7 & "_" & text 9 thru 10
    end tell
  • Mike9586 Level 1 Level 1 (0 points)

    Thank you so much, works fantastically!

  • The Wasson's Level 1 Level 1 (0 points)

    Thank you for your very long history of responses to this thread and all the little "tweak" requests... and yes, i have another:) I am only two weeks into mac ownership (quite a learning curve) and I am using Automator and your Apple script to address what I see as a functionality gap within iPhoto and/or Image Capture - The ability to customize file names when importing.

     

    Here is my general workflow:

    A -

    1. Import photos into folder

    2. rename photos based on date taken (YYYY_MM_DD_HHMMSS)

    3. move photos into folders according to (YYYY-MM-MONTH)-  2014 - 09 - September (the 09 is the month not the day)

     

    B -

    1. Take selected photos and add prefix name to the end of the prefix  (e.g. 2014_09_13_181232 - Jr.'s 1st Birthday)

     

    C -

    1. Import all my properly dated subfolders into iPhoto

    2. move to external backup drive.

    3. Delete from mac


    I understand that iPhoto doesn't really showcase the file name once its in the db, but this method helps me in 3 ways 1) iPhoto uses the folder structure and the prefix info to help auto - organize (events and titles) upon import without me having to redo much, 2) if I export/email/upload a photo it will be named properly 3)  If i ever decide  to switch photo management tools i will have some sort of hope rebuilding an unmanaged folder structure with good file names instead of a whole bunch of IMG 001s. 

     

    I have the Automator workflow about 95% figured out and I think i can get the rest of the way there with some trial and error.  However hoping you could help with the folder name tweak I have described in A-3 above which uses a combo of the two get date examples you illustrated - by using both month format types (numerical and text).  Also, I would prefer to use the date taken rather than date created.  This is usually not an issue because they are the same when imported from the camera/iPhone, but this would help use the same code for files that were received some other way and may have changed the original date created. 

     

    Thanks again for your good work. 

  • mortenda Level 1 Level 1 (0 points)

    Hello,

     

    I think that this might be what I'm looking for, but if not, I'm wondering if you might be able to help me.

     

    I've recently discovered Automator, but I can't figure out how to get it to do what I need it to do. My pictures are saved in folders by the date they were created. In updating to new downloading software several times over several years, the format of the dates is not the same, thus they are no longer in chronological order in my larger "Photos" folder. I tried re-naming the folders through automator based on date created, but it pulls the date the folder was created, NOT the date the pictures were created, which is not accurate. How do I tell automator to look at the content of the folders and to either re-name them or create new folders based on the creation date of the pictures? Or will this script work (with modification) to accomplish this task?


    My pictures are already organized, so really, what I want to do is just re-name the folders to a uniform yyyy_mm_dd format. Can you help?


    Many, many thanks in advance!



  • DARB78 Level 1 Level 1 (0 points)

    I'm not great at applescript. I successfully used this script to organize my entire library about a month back. I downloaded pictures from my camera today and wanted to organize them so I ran the script again and started getting an error "number -1721". I removed the expression {input, parameters} and was able to get past the first error but then ended up with a second error "The variable input is not defined." number -2753 from "input". Any thoughts on what changed and why this suddenly doesn't want to work any more?

  • pointvicente Level 1 Level 1 (10 points)

    I agree this would be a great tool for Yosemite. But I can't get it to work either but I'm sure some one knows how.  I get AppleScriptError "Null"