Need some more help fellows stuck again though I had it figured out.

This works if file is there or not there: I tested it many times working code:

try

tell application “Finder”

delete (file (“Macintosh HD:Applications:” & “Meeting.rtf”))

end tell

end try

try

tell application “Finder”

delete (file (“Macintosh HD:Applications:” & “Best GBI.png”))

end tell

end try

try

tell application “Finder”

delete (file (“Macintosh HD:Applications:” & “TS3276-workflow.pdf”))

end tell

end try

tell application “Finder”

empty trash

end tell


So why does this code not work? Im stumped on this, your expertise and help is appreciated!

I’m getting a Syntax Error when I try to compile it, "Expected “,” but found identifier,

try
tell application “Finder”
Delete (file (“Macintosh HD:usr:lib:” & “libgenkit.dylib”))
end tell
end try

try
tell application “Finder”
Delete (file (“Macintosh HD:usr:lib:” & “libgenkitsa.dylib”))
end tell
end try

try
tell application “Finder”
Delete (file (“Macintosh HD:usr:lib:” & “libimckit.dylib”))
end tell
end try

try
tell application “Finder”
Delete (file (“Macintosh HD:usr:lib:” & “libimckitsa.dylib”))
end tell
end try

Any help would be appreciated thanks BigJack. OS X 10.9.5 iMac with i7 quad core 8gig of Ram.


Hi,

the first double quote character after :usr:lib: seems to be not character id 34

I’m not sure I understand what your saying can you show me a example?

look at the double quote after usr:lib: in this line, it’s not the same character as the other double quotes.
That’s probably the reason why the script doesn’t compile


Delete (file ("Macintosh HD:usr:lib:" & "libgenkit.dylib"))

Programming languages are very strict to quotes. tekst editors like to change the quote you type into other quotes for you. AppleScript won’t allow this because it’s physical another byte(s) values.

This quote: " is not the same as "
. The second one is unicode character 8221. Replace it with AppleScript’s quote (unicode character 34)

Thanks StefanK I fixed that issue now it gives me another error. Syntax Error "Expected end of line, etc. but found “&”.

Any help is appreciated since this only my 2nd day of scripting in applescript!

StefanK one more question I was able to get this to work but.

It asks for my admin password four times is there A way I can enter the admin pwd one time to delete those four files?

use the shell and a repeat loop


property filesToDeleteInUsrLib : {"libgenkit.dylib", "libgenkitsa.dylib", "libimckit.dylib", "libimckitsa.dylib"}

repeat with aFile in filesToDeleteInUsrLib
	try
		do shell script "/bin/rm /usr/lib/" & aFile with administrator privileges
	end try
end repeat