View Full Version : Batch delete users cache folder

09-05-2007, 09:29 AM

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?


The userdata are stored on a Xsan Volume like this:


... 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:


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.

09-05-2007, 10:32 AM
It sounds like you don't know about wildcards - see this Unix FAQ:

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

nipodrom, the path you want to delete is:

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

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