Created
September 30, 2012 17:46
-
-
Save mherb/3807895 to your computer and use it in GitHub Desktop.
Apple Script to clean Safari Cache, History, Webpage Previews, Local Storage and Databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Can be executed from Terminal using "osascript safari_cache_clean.scpt" | |
-- inspired by http://www.macuser.de/forum/f30/safari-alle-cache-544226/ | |
set appname to "Safari" | |
if appIsRunning(appname) then | |
set started to true | |
-- Quit App | |
tell application appname to quit | |
else | |
set started to false | |
end if | |
-- Remove files | |
do shell script "rm -f ~/Library/Safari/history.plist" | |
do shell script "rm -f ~/Library/Safari/HistoryIndex.sk" | |
do shell script "rm -rf ~/Library/Safari/LocalStorage" | |
do shell script "rm -rf ~/Library/Safari/Databases" | |
do shell script "rm -f ~/Library/Caches/com.apple.Safari/Cache.db" | |
do shell script "rm -rf ~/Library/Caches/com.apple.Safari/Webpage\\ Previews" | |
do shell script "rm -rf ~/Library/Caches/Metadata/Safari/History" | |
-- Restart App if it was running before | |
if started then | |
tell application appname to activate | |
end if | |
-- See http://techblog.willshouse.com/2012/02/21/applescript-check-application-is-running/ | |
on appIsRunning(appname) | |
tell application "System Events" to (name of processes) contains appname | |
end appIsRunning |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For chrome - windows : echo PlaceholderChromeClearCache, mac osascript -e 'tell application "Google Chrome" to delete (every history item whose date last visited is less than (current date))' for firefox - echo PlaceholderFirefoxClearCache & rm -rf ~/Library/Caches/Firefox/Profiles//cache2/"