What I’m trying to do is delete a folder and all its contents at this location.
/Macintosh HD/Library/InputManagers/CTLoader/
"CTLoader is the folder I’m trying to kill, I put a test one at that location but my script isn’t touching it at all.
I need your savvy and wisdom my masters!
tell application “System Events”
set libraryFolder to path to library folder
end tell
try
tell application “Finder”
if exists folder “CTLoader” of libraryFolder then
delete folder “CTLoader” of libraryFolder
end if
end tell
end try
Ok I tried that and there is no error but it deletes nothing. Here is were I’m at.
try
tell application “Finder”
if exists folder “CTLoader” of folder “InputManagers” of libraryFolder then
delete folder “CTLoader” of folder “InputManagers” of libraryFolder
end if
end tell
end try
try
tell application "Finder"
if exists folder "CTLoader" of folder "InputManagers" of libraryFolder then
beep
delete folder "CTLoader" of folder "InputManagers" of libraryFolder
end if
end tell
end try
Also, one other thing is that if you use the try/error/end try block without the error part then it doesn’t tell you anything. Here’s an example of using the error block:
try
display dialog "hello"
display dialog "user didn't cancel"
on error err_msg
display dialog err_msg
end try
If you check the existence of a folder, a try block is not needed
set libraryFolder to path to library folder
tell application "Finder"
if exists folder "InputManagers:CTLoader" of libraryFolder then
delete folder "InputManagers:CTLoader" of libraryFolder
end if
end tell
There was no beep so it is not finding the folder I must be doing something wrong?
tell application “System Events”
set libraryFolder to path to library folder
end tell
tell application “Finder”
if exists folder “InputManagers:CTLoader:” of folder of libraryFolder then
beep
delete folder “InputManagers:CTLoader:” of folder of libraryFolder
end if
end tell
tell application "Finder"
if exists folder "InputManagers:CTLoader:" of folder of libraryFolder then
beep
delete folder "InputManagers:CTLoader:" of folder of libraryFolder
end if
end tell
of folder of libraryFolder does not look right. There’s an extra of folder in there.
Edited: don’t worry. I know how it is when you’re rushing to do something.
Edited: also, you are getting many different inputs.
Edited: what you can do to get a good reference is to use something like:
choose folder
or:
choose file
You can then use that reference. Later on, you can use more advanced stuff once you get it working.