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


Click here to return to the 'Fast trash emptying via Unix script turned into an app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fast trash emptying via Unix script turned into an app
Authored by: tedw on Jul 21, '09 07:55:08AM
Platypus is fine if that's what you want to do, but there's no need for it in this case; this script can be run straight from OS X using applescript. just add the above script into a text string and use applescript's do shell script command to launch it, as follows:
set theScript to "#/bin/sh
cd ~/.Trash
dirs=`find ~/.Trash -type d | wc -l`
fils=`find ~/.Trash -type f | wc -l`
byts=`du | tail -1`
(( dirs = dirs -1 ))
echo \"$dirs: directories\"
echo \"$fils: files \"  
echo \"$byts: bytes \"   

rm -Rf ~/.Trash/*
echo Return code: $?"

do shell script theScript
paste this is Script Editor, and either save it as an application to run on its own, or run it as a script from QuickSilver, Butler, apple's Script Menu, or whatever other script launcher you might use.

[ Reply to This | # ]
Fast trash emptying via Unix script turned into an app
Authored by: wallybear on Jul 21, '09 10:39:30AM
There's an error in the script: du returns block count (with blocks of 512 bytes), not bytes.
Use the parameter -k if you want Kb, or, better, use the -h parameter for "human readable" value (with Kb/Mb/Gb scaling).
Moreover, using the -s parameter you can omit the 'tail -1' command; so:

byts=`du | tail -1`

becomes

byts=`du -sh`


[ Reply to This | # ]
Fast trash emptying via Unix script turned into an app
Authored by: wallybear on Jul 22, '09 11:05:41AM

mmmhmm... my comment was for the main article, not an answer to the above reply.



[ Reply to This | # ]
Fast trash emptying via Unix script turned into an app
Authored by: encro on Jul 21, '09 02:11:22PM

That is really a waste of what Applescript is meant for.

All you really need to do is rename cleanup.sh to cleanup.command and set the executable bit for a double clickable file.

mv cleanup.sh cleanup.command
chmod 755 cleanup.command


---
Steve



[ Reply to This | # ]