Jump to content

Hotkey to trigger file move


Recommended Posts

Posted

Am just migrating to Alfred from Quicksilver and one of my much used triggers in QS was ALT+CMD+M which would move the selected file/s in folder to a fixed directory ("~/Documents/Scans') that Hazel was watching and would then file them in the appropriate directories based on its (Hazel's) rules.

 

This way if I had files sitting on my Desktop or in my Downloads folder or misfiled somewhere, I could select, hit the hotkey trigger and Hazel would do the rest.

 

Can I get something like this working in Alfred? Can't quite figure out how to Move the selected files in a Workflow and how to specify the target directory.

 

Thanks!

Posted

Hey Vitor,

 

Thanks for the quick response!

 

A bit different from what I'm used to in QS...

 

But, one bug: when I choose a file in Alfred and run this as a File Action, it moves the chosen file to the Documents directory and renames it as 'Scans' without an extension. 

  • 3 months later...
Posted
On 3/7/2017 at 8:30 PM, vitor said:

 

Precisely. I though you already had it.


This version also makes the directory first, if it doesn’t exist.

 

 

This looks very interesting, but the link is dead.

 

Would it be possible for you to reupload?

Posted (edited)
5 minutes ago, Dynamitleo said:

This looks very interesting, but the link is dead.

 

Would it be possible for you to reupload?

 

I don’t have it anymore. @PopSquirrel might.

Edited by vitor
Posted

 @Dynamitleo Uploaded the workflow here. Yes, it's bash script linked to a File Action. 

 

Just in case there's a problem with the upload, here's the script:

perl -pe 's/[\t\n]/\0/g' <<< "{query}" | xargs -I '{}' -0 mv -n '{}' "${HOME}/${move_to}"

 

And there's a Workflow Environment Variable set (move_to) that contains the path to the folder you want to move to.

 

I use this to dump files that have accumulated all over my workspace (Downloads, Desktop, scanner folder etc.) to a single directory where I use Hazel to file them in appropriate folders according to the file name and type.

 

Very useful! Thanks again, @vitor

  • 1 month later...
Posted

Hi! 

I want to trigger a File Action with a hotkey. Is that possible? 

That is: do CMD+M instead of TAB followed by CMD+1

 

I can of course use a normal hotkey trigger but way I don't get the filepath…

 

Can't download the workflow, maybe the answer is in the workflow above?

 

 

 

Posted

@pontus Not sure about calling a File Action via a hotkey but the workflow I use has nothing other than the script reproduced above and the Workflow Environment Variable. It's a File Action so I call it via a double-CMD tap and then CMD+9 (which is not what you want, I gather). Sorry couldn't be of more help.

Screen Shot 2017-08-14 at 6.41.27 PM.png

Posted

@pontus Well, maybe I can be of a bit more help. Your post started me thinking!

 

So, set up a blank Workflow. Add in a Hotkey trigger. Set the trigger elements to Pass through to workflow and Selection in macOS and in the Related Apps pane add Finder and set the dropdown to have focus.

 

Link this trigger to a Run Script Action. In the Action the settings are /bin/bash with input as {query} and the script is perl -pe 's/[\t\n]/\0/g' <<< "{query}" | xargs -I '{}' -0 mv -n '{}' "${HOME}/${move_to}". Save it and set a Workflow Environment Variable called move_to with the value being the directory you want to move stuff to (I use Documents/Scans).

 

Save and in Finder, select one or more files and trigger your hotkey. Voila!

Posted

@PopSquirrel Thanks for the answers. No, not quite what I was after but a good tip though :)

 

I was improving the Open in Finder tab-workflow (by @mix1009, http://www.packal.org/workflow/open-finder-tab) by making it also work as a File Action. Works like a charm :)

Then, I thought it would be even more neat to be able to do something like CMD+ENTER directly in the folder. Hence the question of triggering a File Action with a hotkey...

 

Not by the computer now but can upload the workflow tomorrow.

 

  • 4 years later...

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...