PDA

View Full Version : Simple Apple script edit




Me1000
Nov 10, 2007, 10:23 PM
So I got this wonderful little application (made with apple script) that goes inside my downloads stack, so that I can click on it, and it deletes everything inside the downloads folder,

However there is a single folder that I need to keep inside the downloads stack,

the folder is named "Download"

this is the script i am trying to edit,

try
tell application "Finder"
set the_items to (every item of (path to downloads folder as alias) whose name is not "Delete All.app")
delete the_items
end tell
on error
tell application "Finder" to display dialog "An error occurred!" with icon 0 buttons {"Damn"} default button 1
end try


It looks obvious what needs to be edited, however I dont even know where to begin when it comes to apple script!

any help would be great,
thanks,
:)



HexMonkey
Nov 10, 2007, 10:42 PM
Try this:

try
tell application "Finder"
set the_items to (every item of (path to downloads folder as alias) whose name is not in {"Download", "Delete All.app"})
delete the_items
end tell
on error
tell application "Finder" to display dialog "An error occurred!" with icon 0 buttons {"Damn"} default button 1
end try

Me1000
Nov 10, 2007, 11:24 PM
Thanks,

I cant try it yet, because I have 2 other files in the stack that cant be moved until later this week... :o

ill post an update when I can...
:)

Me1000
Dec 26, 2007, 08:47 PM
Sorry it took so long to try,
unfortionalty that didn't work.
It removes the folder as well...
:o

HexMonkey
Dec 26, 2007, 08:57 PM
Are you sure that the folder name exactly matches the name of the folder in the script? In your original post you said it was called "Download"; perhaps it was meant to be "Downloads".

Me1000
Dec 26, 2007, 09:04 PM
Well I thought that was the problem to begin with, because there was a space at the end of the folder name but I took the space out, and it still didnt work.
however I just looked again, and found that there was a space in front of the folder name too. I added that to the apple script and it works great now!

Thank You,
:)