PDA

View Full Version : Batch delete users cache folder


nipodrom
09-05-2007, 09:29 AM
Hi!

Need your help. How can I delete the cache folder of multiple user home directories via automatically executed shell script on a Mac OS X Server?

Example:

The userdata are stored on a Xsan Volume like this:

/Volumes/Xsan/userdata/mike
/Volumes/Xsan/userdata/peter
/Volumes/Xsan/userdata/robert
/Volumes/Xsan/userdata/dave
/Volumes/Xsan/userdata/michael

... etc. (total 1629 user home directories)

and in every userfolder is the same folder structur:

Desktop, Documents, Library, Movies, Music, Pictures and Public


The folder which should be removed is:

/username/Library/Caches


The script should go through all 1629 user home directories and delete the entire cache folder. I would like to run this script automatically as a cron job in the night.

Thanks in advance for your help.

hayne
09-05-2007, 10:32 AM
It sounds like you don't know about wildcards - see this Unix FAQ:
http://forums.macosxhints.com/showthread.php?t=40648

fracai
09-05-2007, 10:36 AM
hayne... always trying the "teach a man to fish" approach.

nipodrom, the path you want to delete is:
/Volumes/Xsan/userdata/*/Library/Caches

Read that FAQ though; wildcards are essentially great power and we all know what comes with that.

raymondlewisjone
09-05-2007, 12:40 PM
rm -Rf /Volumes/Xsan/userdata/*/Library/Caches/*

This will only delete the contents of the Caches folder not the actual Caches folder like the script above