Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Folder Action script to change permissions' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Folder Action script to change permissions
Authored by: ddldreaming on Mar 15, '05 10:31:42AM

I was inspired by this hint to address a minor annoyance: files I upload to my website (using scp from the command line or SFTP via Fugu) are assigned the same permissions as the local file, usually 0600. I generally want them to be 0644 (readable by everyone), but sometimes I forget to set them manually. So rather than change my umask, I wrote this Folder Action script and attached it to my 'uploads' folder.


on adding folder items to this_folder after receiving added_items
  tell application "Finder"
    set fold_name to the name of this_folder
    try
      repeat with i from 1 to number of items in added_items
        set new_item to item i of added_items
        set the item_path to the quoted form of the POSIX path of new_item
        do shell script ("/bin/chmod -R +r " & item_path)
      end repeat
    end try
  end tell
end adding folder items to

I saved it to ~/Library/Scripts/Folder Action Scripts/ and wrote another script (also saved there) to attach the first script to subfolders of a folder. This one is as follows:


on opening folder this_folder
  tell application "Finder"
    set script_file to ((path to library folder from user domain as Unicode text) 
      & "Scripts:Folder Action Scripts:add - Make world-readable.scpt" as Unicode text)
    repeat with each_folder in (get every folder of this_folder)
      tell application "System Events"
        attach action to (each_folder as alias) using (script_file as alias)
      end tell
    end repeat
  end tell
end opening folder

They seem to work pretty well. I'm pretty sure others have posted similar scripts before but what the heck, a few more can't hurt. :) (Can I just take this moment to say how much I despise the error reporting in AppleScript? Yecch. Thank you.)



[ Reply to This | # ]
Folder Action script to change permissions
Authored by: goodidea on Jan 08, '06 11:15:43AM

Hello!
This works pretty well and I am glad to have found it (I not very familiar with applescript).

But: it seems not to work is you *replace" an existing item instead of adding one, or am I wrong?

Is it easy to modify the script that it also works in this case???

Greetings! Patrick!



[ Reply to This | # ]