Simple 'Empty Folder' Script Help

When I was a little boy, I used to mess around with Macscript on my old Performa 5200, and it turned out to be my first computer programming language, and I learned about as much as a 9-year old could. Being 19 and low loving my brand new Macbook Pro, I find myself with a bit of a prolem.

Well, maybe not as much as a problem, but just me being lazy. I want to create a script that will empty my Downloads folder for me, because my downloads folder, which is a stack on my dock, has become a little bit of a long process to empty out.

Could I get a little help with the source for this?


Model: Macbook Pro Early 2010
AppleScript: 2.3
Browser: Google Chrome V. 6.0.472.53 Beta
Operating System: Mac OS X (10.6)

I didn’t test this :lol:

tell application "Finder"
	repeat with x in items of (path to downloads folder)
		delete x
	end repeat
end tell

to empty the trash simply put


inside the tell, below end repeat.


tell application "Finder"
	delete items of (path to downloads folder)
end tell

The assumption is, of course, that none of the items is locked. :rolleyes:

Neither of the suggestions worked, I suppose it’s because I’m screwing up the directory somewhere. The downloads folder that I was referring to was the default OS X downloads folder located at /Users//Downloads.
The code I was executing was:

tell application "Finder"
	repeat with x in items of (Users / MjrPwnr / downloads)
		delete x
	end repeat
end tell

The error I was getting was

What am I doing wrong here?

Oh wait, disregard my last post, I figured out what I was doing wrong, I shouldn’t have altered the posted code.:lol:

Thanks. :slight_smile:

Wait, nevermind, it’s still not working.
I need to make up my mind, haha.

AppleScript expects always HFS paths (starting with a disk name and colon separated).
POSIX paths (slash separated) don’t work and your syntax (variables instead of literal string) couldn’t work at all.

As Nigel noted above path to downloads folder returns the alias specifier of the download folder of the current user regardless of the name of the user and the name of the startup disk

What’s simple depends on your previous experience, of course. :wink: