Simple Apple script edit

Discussion in 'Mac Programming' started by Me1000, Nov 10, 2007.

  1. macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #1
    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,

    Code:
    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,
    :)
     
  2. Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #2
    Try this:

    Code:
    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
     
  3. thread starter macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #3
    Thanks,

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

    ill post an update when I can...
    :)
     
  4. thread starter macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #4
    Sorry it took so long to try,
    unfortionalty that didn't work.
    It removes the folder as well...
    :eek:
     
  5. Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #5
    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".
     
  6. thread starter macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #6
    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,
    :)
     

Share This Page