Hi Guys, i'm on an admirable to quest to write a Script which clears my MBP of the following in one Click...
1) Cookies (empty the folder in ~Library)
2) Flash Cookies (all folders and .sol files in ~Preferences/Macromedia)
3) Web Previews (all files in ~Library/Cache/com.apple.Safari)
4) History.plist (file in ~Library/Safari)
5) HistoryIndex.sk (file in ~Library/Safari)
6) TopSites,plist (ile in ~Library/Safari)
7) History Folder (all files in ~Library/Cache/Metadata)
This is the novice Script I've come up with so far to delete this list...
With this Script I can delete everything EXCEPT for Flash Cookies (6 out of 7 isn't bad for a novice) I do have the FLUSH app for deleting Flash Cookies but its stopped working? I copied part of the FLUSH script in my Script above and it used to work just fine, but since adding the Safari Quit command it doesn't work any more. I needed to add "quit Safari" to ensure the History and Top Sites are removed (all in one click). Problem is, running FLUSH now doesn't delete the contents of the Macromedia folder anymore. I have to do it manually. Really confusing, but at 6 out of 7 i'm nearly there!
Does anybody have ANY suggestions why the contents of the Macromedia Folder won't be deleted using my Script?
I'll appreciate any advice. I do want to learn AppleScript further but for now getting this Script completed would be a great start!

Ignore the Script I posted above, the second "end tell" command after activating Terminal is incorrect.
THIS is the correct Script i'm working on:
On your own Mac, if you open all 7 folders from my first post and close all Safari window, you will see that this Script deletes everything EXCEPT for the Flash Cookies in ~Library/Preferences/Macromedia. 6 out of 7.
This is the part of the Script I want to fix, then I've got the ultimate one click solution to clean my Mac after Browsing. Im surprised I haven't come across a similar Script that cleans everything before. This is an admirable quest!
Thanks
Another school boy error. Im working on 3 different versions of this Script so I've pasted the wrong one (again)
The script needs a slight delay before quitting, to ensure all the files are deleted. I use a 2 second delay. Below is the final Script 🙂
Everything in the Script works fine and is deleted... Except for those damn Flash Cookies! What is that part of the Script missing? Is there a better way to word it? Help!
Thanks!

Must say I am REALLY proud of myself 😀
Any kind of "coding" was always too daunting to try on a PC but AppleScript is really intuitive and enabling. I've only been looking at Scripts for the last two weeks but I've managed to answer my own question and complete my First Script!!!
As far as I can tell, the seven locations listed in my first post are all the places nasty-tracker-type-things lurk. My Script deletes them all in a single Click! For those that don't know, copy this command into AppleScript Editor, save it as an Application, add your own ICNS and store it somewhere convenient! When you click your new App it will run the Script, delete everything, and then Close itself!
If you have multiple tabs open in Safari you might be prompted to close them during the Script, so its good practice to finish browsing, Close all Safari tabs and windows, and then run this Script.
I'd like to share this with whoever might find it useful. If anybody has any improvements or alternatives I'd really like to know. But not bad for a first Script aye? 😉






1) Cookies (empty the folder in ~Library)
2) Flash Cookies (all folders and .sol files in ~Preferences/Macromedia)
3) Web Previews (all files in ~Library/Cache/com.apple.Safari)
4) History.plist (file in ~Library/Safari)
5) HistoryIndex.sk (file in ~Library/Safari)
6) TopSites,plist (ile in ~Library/Safari)
7) History Folder (all files in ~Library/Cache/Metadata)
This is the novice Script I've come up with so far to delete this list...
Code:
tell application "Safari"
quit
end tell
tell application "Terminal"
activate
do script "rm ~/Library/Caches/com.apple.Safari/Webpage\\ Previews/*; rm ~/Library/Caches/Metadata/Safari/History/*; rm ~/Library/Safari/History.plist*; rm ~/Library/Safari/HistoryIndex.sk*; rm ~/Library/Safari/TopSites.plist*; rm ~/Library/Cookies/*; ls -R ~/Library/Preferences/Macromedia/Flash*Player | grep -v settings | grep -v preferences | grep .sol | cat -n"
end tell
quit
end tell
With this Script I can delete everything EXCEPT for Flash Cookies (6 out of 7 isn't bad for a novice) I do have the FLUSH app for deleting Flash Cookies but its stopped working? I copied part of the FLUSH script in my Script above and it used to work just fine, but since adding the Safari Quit command it doesn't work any more. I needed to add "quit Safari" to ensure the History and Top Sites are removed (all in one click). Problem is, running FLUSH now doesn't delete the contents of the Macromedia folder anymore. I have to do it manually. Really confusing, but at 6 out of 7 i'm nearly there!
Does anybody have ANY suggestions why the contents of the Macromedia Folder won't be deleted using my Script?
I'll appreciate any advice. I do want to learn AppleScript further but for now getting this Script completed would be a great start!

Ignore the Script I posted above, the second "end tell" command after activating Terminal is incorrect.
THIS is the correct Script i'm working on:
Code:
tell application "Safari"
quit
end tell
tell application "Terminal"
activate
do script "rm ~/Library/Caches/com.apple.Safari/Webpage\\ Previews/*; rm ~/Library/Caches/Metadata/Safari/History/*; rm ~/Library/Safari/History.plist*; rm ~/Library/Safari/HistoryIndex.sk*; rm ~/Library/Safari/TopSites.plist*; rm ~/Library/Cookies/*; ls -R ~/Library/Preferences/Macromedia/Flash*Player | grep -v settings | grep -v preferences | grep .sol | cat -n"
quit
end tell
On your own Mac, if you open all 7 folders from my first post and close all Safari window, you will see that this Script deletes everything EXCEPT for the Flash Cookies in ~Library/Preferences/Macromedia. 6 out of 7.
This is the part of the Script I want to fix, then I've got the ultimate one click solution to clean my Mac after Browsing. Im surprised I haven't come across a similar Script that cleans everything before. This is an admirable quest!
Thanks
Another school boy error. Im working on 3 different versions of this Script so I've pasted the wrong one (again)
The script needs a slight delay before quitting, to ensure all the files are deleted. I use a 2 second delay. Below is the final Script 🙂
Code:
tell application "Safari"
quit
end tell
tell application "Terminal"
activate
do script "rm ~/Library/Caches/com.apple.Safari/Webpage\\ Previews/*; rm ~/Library/Caches/Metadata/Safari/History/*; rm ~/Library/Safari/History.plist*; rm ~/Library/Safari/HistoryIndex.sk*; rm ~/Library/Safari/TopSites.plist*; rm ~/Library/Cookies/*; ls -R ~/Library/Preferences/Macromedia/Flash*Player | grep -v settings | grep -v preferences | grep .sol | cat -n"
delay 2
quit
end tell
Everything in the Script works fine and is deleted... Except for those damn Flash Cookies! What is that part of the Script missing? Is there a better way to word it? Help!
Thanks!

Must say I am REALLY proud of myself 😀
Any kind of "coding" was always too daunting to try on a PC but AppleScript is really intuitive and enabling. I've only been looking at Scripts for the last two weeks but I've managed to answer my own question and complete my First Script!!!
As far as I can tell, the seven locations listed in my first post are all the places nasty-tracker-type-things lurk. My Script deletes them all in a single Click! For those that don't know, copy this command into AppleScript Editor, save it as an Application, add your own ICNS and store it somewhere convenient! When you click your new App it will run the Script, delete everything, and then Close itself!
If you have multiple tabs open in Safari you might be prompted to close them during the Script, so its good practice to finish browsing, Close all Safari tabs and windows, and then run this Script.
I'd like to share this with whoever might find it useful. If anybody has any improvements or alternatives I'd really like to know. But not bad for a first Script aye? 😉



Code:
tell application "Safari"
quit
end tell
tell application "Terminal"
activate
do script "rm ~/Library/Caches/com.apple.Safari/Webpage\\ Previews/*; rm ~/Library/Caches/Metadata/Safari/History/*; rm ~/Library/Safari/History.plist*; rm ~/Library/Safari/HistoryIndex.sk*; rm ~/Library/Safari/TopSites.plist*; rm ~/Library/Cookies/*; rm -r ~/Library/Preferences/Macromedia/*"
delay 1
quit
end tell



Last edited by a moderator: