Jump to content
Bhishan

[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?

 

Required:

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

 

 

My attempt workflow is here.

 

 

Pesudocode:

```

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.

 

Thanks.

 

Edited by Bhishan

Share this post


Link to post

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.

Share this post


Link to post

Thanks  a lot, I figured it out.

-- cd to Downloads
try
	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
try
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

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...