I am trying to get my script to watch not only a folder but also all the sub folders and files within it.
It’s important that I only watch and change permissions on new files because there are way too many files involved.
Thanks, Reid
on adding folder items to this_folder after receiving added_items
repeat with anItem in added_items
try
tell application "Finder"
set owner privileges of anItem to read write
set everyones privileges of anItem to read write
set group privileges of anItem to read write
end tell
end try
end repeat
end adding folder items to
I don’t think this is possible with a single script. That is, a folder action attached to a folder is invoked only an item is added to that folder, not to its sub-folders. But I’m not sure and haven’t the time to test right now.
So: either attack a folder action to the subfolders (which may be possible with applescript – an applescript could attach a folder action to a folder under OS9; not sure about X), or store the time when the folder was last examined, then files added after that time are new files. If the latter course is chosen, the applescript should probably run automatically at set times (e.g., a cron job or use iDo Script Scheduler) instead of be a folder action.
Hi, I think I got something for you. I wrote this script for a friend, who was going nuts from changin permissions in his public folder.
It makes the logged in user the owner and set permissions to “everything allowed to everybody” or 777. It runs on OS X only.
on adding folder items to thisfolder after receiving filelist
repeat with i from 1 to (count filelist)
set thisfile to posixPath (item i of filelist as alias) with quotes
changepermissions(thisfile)
end repeat
set rep to display dialog "New Data arrived.
open Folder?" buttons {"no", "yes"} default button "yes" giving up after 10
if button returned of rep is "yes" then
tell application "Finder"
open thisfolder
--activate
select every item of filelist
end tell
end if
end adding folder items to
on changepermissions(thisfile)
set x to do shell script "who am i"
set myname to first word of x
set cmd to "chown -R " & myname & " " & thisfile
do shell script cmd with administrator privileges --password ""<- insert your admin-password to get rid of the annoying dialog
set cmd to "chmod -R 777 " & thisfile
do shell script cmd
end changepermissions