Jump to content

[SOLVED] How to Assign Keyboard Shortcut to empty Downloads and Trash Both?

Recommended Posts

This might be a very simple question, but I could not find an easy way to assign a keyboard shortcut to run Alfred with another workflow command arguments:


For example:

In Alfred:   " throw"    command will throw all the contents from the Downloads folder to Trash Folder.  (workflow: Trash Downloads  axelpeigne.trashdownloads)

In Alfred: "emptytrash" command will empty the Trash contents using Alfred built-in command.


Is there a way to combine these two commands and assign keyboard shortcuts for them?



ctrl-shift-E    should run   alfred commands `throw` and then `emptytrash`.



My attempt workflow is here.





tell application "Alfred 3" to run command "throw"

tell application "Alfred 3" to run command "emptytrash"



Then just prepend a HOT key trigger to this File Script.

I just don't know the actual AppleScript commands.




Edited by Bhishan
Link to comment

Yes, I believe so.  You can take the first workflow (`throw`) and append a _System Command_ action, for which you would choose "Empty Trash".  Then prepend to all of this a hotkey that triggers this sequence of events.  No AppleScript ought to be needed.

Link to comment

Thanks  a lot, I figured it out.

-- cd to Downloads
	set folderPath to POSIX file "{query}"
on error
	set folderPath to (path to downloads folder as text)
end try

-- try to delete items in Downloads if any
tell application "Finder"
	set itemsToDelete to every item of folder folderPath
	delete itemsToDelete
end tell
end try

-- empty trash
tell application "Finder"
    empty trash
end tell


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...