If you’re file sharing, you’ve probably run into a situation where files created on one users system and stored on yours are not writable by another user. This folder action script fixes the permissions for all files and folders dropped into it.
on adding folder items to this_folder after receiving added_items
repeat with i from 1 to number of items in added_items
tell application "Finder"
set new_item to item i of added_items as alias
set item_path to the quoted form of the POSIX path of new_item
set all_files to every file in folder new_item
set all_folders to every folder in folder new_item
end tell
do shell script ("/bin/chmod -R g+w " & item_path)
my chgfiles(all_files)
my chgfolders(all_folders)
end repeat
end adding folder items to
on chgfiles(flenames)
set n to count of items in flenames
repeat with j from 1 to n
tell application "Finder"
set nwitem to item j of flenames as alias
set the item_path to the quoted form of the POSIX path of nwitem
do shell script ("/bin/chmod -R g+w " & item_path)
end tell
end repeat
end chgfiles
on chgfolders(foldernames)
tell application "Finder" to set n to count of items in foldernames
repeat with j from 1 to n
tell application "Finder"
set nwitem to item j of foldernames as alias
set item_path to the quoted form of the POSIX path of nwitem
set subfiles to every file in nwitem
set subfolders to every folder in nwitem
end tell
do shell script ("/bin/chmod -R g+w " & item_path)
my chgfiles(subfiles)
my chgfolders(subfolders)
end repeat
end chgfolders