Applescript to Empty Downloads Folder

I’m not good at scripting and I could use some help with making a script that empties the downloads folder.

Here you go:

tell application "Finder"
	set allDownloads to every item of folder (path to downloads folder as text)
	move allDownloads to trash
end tell

Immediately remove files with interference of the trash:

set downloadsFolder to (path to downloads folder)
set allItems to list folder downloadsFolder without invisibles

repeat with i in allItems
	set myItem to (downloadsFolder as text) & i
	do shell script "rm -fR " & quoted form of (POSIX path of myItem)
end repeat

Hope it helps,
ief2

Hello.

That is a very dangerous way to empty the download folder, at least for someone I happen to know.:slight_smile:
Because the stuff is gone for ever.
With the other way around, you can actually undo stuff if you make a local rm command which moves the items to the trash instead. :wink:

Second thoughts: I guess it is okay if you use Time Machine first.

Best Regards

McUsr

Much appreciated.:smiley: