Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

noobsauce

macrumors member
Original poster
Mar 23, 2010
57
0
I am trying to make a simple script that permanently deletes my flash cache, but whenever I run the script neither of the files are deleted and the applescript window returns the result "". Is this script correct?
Code:
try
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash Player/#SharedObjects"
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash Player/macromedia.com"
end try
EDIT: The second ~/ has been removed
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
Try adding \ before the space in the path in order to escape it, or add single quotes around the whole path. Also, you can catch any errors given.

Code:
try
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash\ Player/#SharedObjects"
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash\ Player/macromedia.com"
  on error error_message
    display alert error_message
end try
 

Caleb531

macrumors 6502
Oct 17, 2009
289
0
Better yet, use the quoted form of the path to take care of the spaces automatically:

Code:
set thePath to "~/Library/Preferences/Macromedia/Flash Player/macromedia.com"
set thPath to quoted form of thePath
 

Bill McEnaney

macrumors 6502
Apr 29, 2010
295
0
I don't know AppleScript, so I don't know the advantages of using it to delete those files. But why not just write a bash script that contains two "rm" commands? If I wanted to write something like this:

rm -rf cache_1
rm -rf cache_2

Naturally, you need to replace "cache_1" and "cache_2" with names of the things you need to delete.

Then I'd save the two lines in a file called, say "delete_caches" and type "chmod +x delete_caches" to make the script executable.
 

noobsauce

macrumors member
Original poster
Mar 23, 2010
57
0
Naturally, you need to replace "cache_1" and "cache_2" with names of the things you need to delete.

Does it have to be names or can I also use or paths? I am new to scripting.
 

Weaselboy

Moderator
Staff member
Jan 23, 2005
34,128
15,593
California
I am trying to make a simple script that permanently deletes my flash cache, but whenever I run the script neither of the files are deleted and the applescript window returns the result "". Is this script correct?
Code:
try
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash Player/#SharedObjects"
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash Player/macromedia.com"
end try
EDIT: The second ~/ has been removed

Sorry to resurrect an old post, but thought it might help people who discover this thread in a Google search.

Use this Applescript with the asterisk in the Flash*Player section and it will work.

Code:
try
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash*Player/#SharedObjects"
	do shell script "rm -rf ~/Library/Preferences/Macromedia/Flash*Player/macromedia.com"
end try
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.