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

Click here to return to the 'Folder Action' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Folder Action
Authored by: MVasilakis on Sep 18, '09 10:40:06AM

Now all we need is an Automator script or Applescript that will compress all files moved into a folder.

[ Reply to This | # ]
Folder Action
Authored by: tedw on Sep 18, '09 12:07:16PM
the script is easy:
on adding folder items to thisFolder after receiving theseItems
	set destinationPath to "/POSIX path/to/destination/folder"
	repeat with thisItem in theseItems
		set cmd to "ditto --hfsCompression " & quoted form of POSIX path of thisItem & " " & destinationPath
		do shell script cmd with administrator privileges
	end repeat
end adding folder items to
the 'with administrator privileges' part is unnecessary (and annoying) if you're compressing files you have ownership of. It authenticates you whether it needs to or not.

[ Reply to This | # ]
Folder Action
Authored by: wgscott on Sep 20, '09 11:13:34AM

I'm pretty certain you always need to have sudo to run the ditto --hfsCompress command.

[ Reply to This | # ]
Folder Action
Authored by: tedw on Sep 20, '09 02:19:49PM
never use sudo when calling shell scripts from applescript - opens a security hole. that's what 'with administrator privileges' is for. see this tech note

[ Reply to This | # ]
Authored by: TruePath on Feb 02, '10 03:32:46PM

That attitude probably creates more security holes than all technical errors put together.

Security is not an absolute matter, nor does it have the same requirements everywhere. Insisting on following rigid little rules like this creates annoyances and inconviences that people then respond to by circumventing the security mechanism entierly, e.g., telling anyone who sits down at the machine their password so they can run secure processes, chowing all the files to their own user, etc..

For instance on my laptop I add myself to the wheel group and let the wheel group use sudo without a password. Would I do this on a corporate machine or webserver? No! But does that make it a security risk on my laptop? No. The point of security on my laptop is to protect my private documents and files. If they already have access to my user account the game is over.

[ Reply to This | # ]