I have a few probably noob questions about Apple scripting
in the line
do shell script "rm -R '~/Suitcase Server Fonts/*'"
I am unable to to delete the information in side Suitcase Server Fonts, I think it is because I cant figure out how to make it understand the Space in the name of the directory
2)in the line
do shell script "rm /applications/QuarkXPress/JAWS/ttemp/*.ps"
there are files in the in the directory called whatever.ps but they are not deleted. and i have no idea why not i hope i just made a mistake
using the try will any of the rm statements that fails end the try statement. If so should i have to make a try for each rm?
Is there a easy way to delete all the sub Dirs in a directory with out deleting the main directory or any of the files in the main directory ( hope that makes sense)
Thanks alot
see below for the full script
try
do shell script "rm ~/Library/Preferences/com.quark.QuarkXPress.plist"
do shell script "rm ~/Library/Preferences/com.quark.QuarkCopyDesk.plist"
do shell script "rm ~/Library/Preferences/com.extensis.suitcase.plist"
do shell script "rm -R '~/Library/Preferences/Suitcase prefernces/'"
do shell script "rm -R '~/Suitcase Server Fonts/*'"
do shell script "rm -R ~/Library/Preferences/Quark"
do shell script "rm /applications/QuarkXPress/QPS/*"
do shell script "rm /applications/QuarkCopyDesk/QPS/*"
do shell script "rm /applications/QuarkXPress/JAWS/ttemp/*.ps"
do shell script "rm /System/Library/Caches/com.apple.ATS.System.fcache"
do shell script "rm /System/Library/Caches/com.apple.ATSServer.FODB_System"
do shell script "rm /System/Library/Caches/fontTablesAnnex"
do shell script "rm /Library/Caches/com.apple.ATS/501/Classic.fcache"
do shell script "rm /Library/Caches/com.apple.ATS/501/Local.fcache"
do shell script "rm /Library/Caches/com.apple.ATS/User.fcache"
do shell script "rm /Library/Caches/com.apple.ATS/Classic.fodb"
do shell script "rm /Library/Caches/com.apple.ATS/Local.fodb"
do shell script "rm /Library/Caches/com.apple.ATS/User.fodb"
do shell script "rm /Library/Caches/com.apple.ATS/FondResourceCache"
end try
I would add some logging features though so you know what commands fail (I have an app very similar but written in XCode to provide a graphical feedback =))
yes there is and here is an example.
set base_folder_path to "whatever"
-- if you have not escaped spaces with \\ base folder path then use quoted form of
-- include the * after the base folder path else the base folder itself will be returned in the find command
do shell script "/usr/bin/find " & base_folder_path & "* -type d -print0 | /usr/bin/xargs -0 /bin/rm -rf"
set remove_commands to {¬
"rm -f ~/Library/Preferences/com.quark.QuarkXPress.plist", ¬
............
"rm -f /Library/Caches/com.apple.ATS/FondResourceCache"}
repeat with a_command in remove_command
removeIt(a_command)
end repeat
on removeIt(a_command)
try
do shell script a_command
end try
[b]( If end try then write a_command to log?)<--------------[/b]
end removeIt
global logRef
set logRef to ((path to desktop) as Unicode text) & "Script Log.txt"
try
close access file filepath
end try
set logRef to (open for access file filepath with write permission)
set eof logRef to 0
(*
your normal script including the set remove commands
and the repeat loop
*)
close access logRef
on removeIt(a_command)
try
do shell script a_command
on error errMsr number errNum
write errNume & tab & errMsg & return to logRef
end try
end removeIt