Setting file labels with AppleScript

Discussion in 'Mac Programming' started by lennyla9, May 1, 2007.

  1. lennyla9 macrumors newbie

    Joined:
    Feb 18, 2007
    #1
    I'd like to write a folder action to automatically apply a colour label when a file is opened.

    I've been having a look at how todo this but I'm new when it comes to folder actions, AppleScript and automator.

    I'd originally thought the best way todo to was to simply apply the label when the last date opened was not null. Unfortunately all of the files report the date they were copied to their folder as their last opened date, even though I have not opened them!

    Could someone give me a hint as to how I might achieve this?
     
  2. MongoTheGeek macrumors 68040

    MongoTheGeek

    Joined:
    Sep 13, 2003
    Location:
    Its not so much where you are as when you are.
    #2
    on adding folder items to aFolder after receiving itemlist
    repeat with anitem in itemlist
    tell application "Finder" to set label index of anitem to 2
    end repeat
    end adding folder items to

    save that script in the folder action scripts folder and then attach it to the folder.
     
  3. lennyla9 thread starter macrumors newbie

    Joined:
    Feb 18, 2007
    #3
    Thanks for your help. Unfortunately the script doesn't work.

    I've saved it in the 'Library\Scripts\Folder Action Scripts' and attached it to the relevant folder.

    Nothing happens when I open any of the files.
     
  4. MongoTheGeek macrumors 68040

    MongoTheGeek

    Joined:
    Sep 13, 2003
    Location:
    Its not so much where you are as when you are.
    #4
    It changes the label when the files are added to the folder
     
  5. lennyla9 thread starter macrumors newbie

    Joined:
    Feb 18, 2007
    #5
    That's not what I want it todo. I want the colour to change when the file is opened.
     

Share This Page