Hi All, as requested, here is the script:
Code:
# Script to clean up cached data items that tend to accumulate over
# time on the computer. Cleans several things:
# 1. Clean up cached thumbnails
# 2. Clean up the .bash_history file
# 3. Clean up "recently used" accumulators, playlist histories, etc.
# 4. One step clean up of Firefox cookies, histories, etc.
# 5. One step cleanup of Safari cookies, histories, etc.
# 1. Thumbnails
rm -f /Users/mac57/.thumbnails/large/*
rm -f /Users/mac57/.thumbnails/normal/*
# 2. Bash History
rm -f /Users/mac57/.bash_history
# 3. Various "Recently Used" trackers, playlist histories, etc.
rm -rf /Users/mac57/.recently-used
rm -rf /Users/mac57/.gqview/history
rm -rf /Users/mac57/.gqview/thumbnails
cp -f /Users/mac57/.gimp-2.2/documents.persist /Users/mac57/.gimp-2.2/documents
cd /Users/mac57/Library/Preferences
cp "Windows Media Player Prefs-default.txt" "Windows Media Player Prefs"
cd
# 4. Firefox cookies, downloads, history - one step cleanup
cd /Users/mac57/Library/Application\ Support/Firefox/Profiles/sy0jbj2k.default
cp cookies.persist.txt cookies.txt
cp downloads.clear.rdf downloads.rdf
cp history.clear.dat history.dat
# 5. Safari cookies, downloads, history, cache - one step cleanup
cd /Users/mac57/Library/Cookies
cp cookies.persist.plist cookies.plist
cd /Users/mac57/Library/Safari
cp Downloads.plist.persist Downloads.plist
cp History.plist.persist History.plist
cd /Users/mac57/Library/Caches
rm -rf Safari
mkdir Safari
# Display the result
echo " "
echo "Caches Cleared - Disk Utilization:"
echo "Filesystem Size Used Avail Capacity Mounted on"
df -h | grep -i disk
echo " "
Note that you will need to change the references to "mac57" to your userid, and you will also need to change the name of the Firefox sub directory where it keeps all the cookies etc. to match your system.
Also note that I have taken the same approach to Firefox/Safari history and download lists as I have to cookies, saving off a standard minimal one (always named like "something.persist.txt") and then overwriting the existing one with it. In order for this script to work "as is" for you, you will need to do the same.
Also, I have GIMP loaded on my machine, and have included it's documents list in the clean up too. If you don't have GIMP on your machine, just delete that part of the script.
To use this script, copy and paste it into a simple text file, and save that file in your home folder as filename "clean" (or whatever name you like). If you are an advanced user and have your own personal bin folder, place it there. If you are not, your home directory is just fine, and is what is assumed in the below.
Now open a Terminal.app session. Type in "ls" and Enter and you should see your script file there in the list of files. Type the following to make the script executable:
Thats it - all ready to use.
From now on, when you want to clean out your Firefox, Safari, etc. caches, just startup Terminal.app and type:
As a useful data point, this script prints out your disk usage at the end. You likely won't see it change as a result of this script running, but when I first put the script together, I thought I might, and I have liked to see the result ever since, so I leave it there.
Enjoy! ...and let me know if you have any questions.