"do shell script /usr/sbin/chown" does not work as a folder action...

Hello and good afternoon,

I wnat to uste the following script to change the User of files and folder that are dropped into a specific folder.
Background of this:

  • User1 is my main account, User2 a tryout account
  • sometimes User2 needs files from User1
  • User2 can open the files from User1, but User2 is not able to change comments or what ever of the exchanged file
  • so I created an “exchange-folder” where User1 drops the files for User2 in
  • a folder action (script is below) shall change the user from User1 to User2…
  • the “exchange-folder” is set up to be used by both users via system preferences “sharing”

but this doesn’t work. The script is not called when adding files to the “exchange-folder” (the folder is located on /exchange-folder).
I hope someone has a clue for me to get this working. THX in advance


on adding folder items to watchfolder after receiving addeditems
	repeat with addeditem in addeditems
		set iteminfo to info for addeditem
		if folder of iteminfo then
			tell application "Finder"
				set folderitems to entire contents of addeditem
			end tell
			repeat with folderitem in folderitems
				do shell script "/usr/sbin/chown IUAS:staff " & quoted form of POSIX path of folderitem & "\"" password "xxx" with administrator privileges
			end repeat
		end if
		do shell script "/usr/sbin/chown IUAS:staff " & quoted form of POSIX path of addeditem & "\"" password "xxx" with administrator privileges
	end repeat
end adding folder items to

Greeting from Madrid

Hi,

addeditem is an alias. An alias has a POSIX path property
folderItem is a Finder file specifier. You have to coerce it to a string path or to an alias to get the POSIX path

The quote after the POSIX path in the shell script lines probably causes an error.
Unfortunately folder action scripts fail silently without any error messages


on adding folder items to watchfolder after receiving addeditems
	repeat with addeditem in addeditems
		set iteminfo to info for addeditem
		if folder of iteminfo then
			tell application "Finder"
				set folderitems to entire contents of addeditem
			end tell
			repeat with folderitem in folderitems
				do shell script "/usr/sbin/chown IUAS:staff " & quoted form of POSIX path of (folderitem as alias) password "xxx" with administrator privileges
			end repeat
		end if
		do shell script "/usr/sbin/chown IUAS:staff " & quoted form of POSIX path of addeditem password "xxx" with administrator privileges
	end repeat
end adding folder items to

stefan… you ar my new best friend :wink:

thx very much. think I have to get deeper into the alias and so on things…

THX. it work like a charm now :wink:

PS: I edited the script above removing the else part.
Your original syntax to change owner and group of addedItem is correct