folder action script - how to?

Posted:
in Genius Bar edited January 2014
I'd like to add a particular folder action to a given folder. This folder action script should label every ".pdf" inside the folder with a particular color, which i have choosed before. Example: if i drag a "pdf" into that particular folder, that pdf should change its label. Or, else, if i save a .doc document as a ".pdf" into the same folder (that one with folder action) the pdf should change its label. So either of both ways should be possible. Drag a new "pdf" into that particular folder OR save as pdf into that folder. How to?



best

Comments

  • Reply 1 of 3
    costiquecostique Posts: 1,084member
    The script:

    Code:


    property extension_list : {"pdf", "PDF"}

    property color_label_index : 1



    on adding folder items to this_folder after receiving these_items

    try

    repeat with i from 1 to number of items in these_items

    set this_item to item i of these_items

    set the item_info to the info for this_item

    if (name extension of the item_info) is in the extension_list then

    tell application "Finder"

    set label index of this_item to color_label_index

    end tell

    end if

    end repeat

    on error

    display dialog "Error"

    end try

    end adding folder items to





    Paste it in Script Editor, save it in ~/Library/Scripts/Folder Action Scripts/, then attach it to the desired folder. Edit the number on line 2 to get the desired label color. Hope this helps.
  • Reply 2 of 3
    vox barbaravox barbara Posts: 2,021member
    wow, just tried it out, ... i'am just overwhelmed, it is working as i wished it should work. You made my life easier as it never was before.



    Thanks so much.



    Costique you are the best.
  • Reply 3 of 3
    costiquecostique Posts: 1,084member
    Quote:

    Originally posted by Vox Barbara

    wow, just tried it out, ... i'am just overwhelmed, it is working as i wished it should work. You made my life easier as it never was before.



    Good.

    Quote:



    Thanks so much.



    Costique you are the best.




    Oh, it was really easy. Anyway, thank you for appreciation.
Sign In or Register to comment.