PopSquirrel Posted March 7, 2017 Posted March 7, 2017 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!
vitor Posted March 7, 2017 Posted March 7, 2017 (edited) There you go. Thrown together pretty fast, but should work reliably. You use it as a File Action. Edited March 7, 2017 by vitor
PopSquirrel Posted March 7, 2017 Author Posted March 7, 2017 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.
deanishe Posted March 7, 2017 Posted March 7, 2017 You need to create the directory before you can move stuff into it.
vitor Posted March 7, 2017 Posted March 7, 2017 47 minutes ago, deanishe said: You need to create the directory before you can move stuff into it. Precisely. I though you already had it. This version also makes the directory first, if it doesn’t exist. Dynamitleo 1
PopSquirrel Posted March 8, 2017 Author Posted March 8, 2017 Mea culpa. That was dumb of me. Thanks, it works perfectly! Vivek
Dynamitleo Posted June 21, 2017 Posted June 21, 2017 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?
vitor Posted June 21, 2017 Posted June 21, 2017 (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 June 21, 2017 by vitor
Dynamitleo Posted June 21, 2017 Posted June 21, 2017 Okay. In the meantime, i will continue searching Google for an answer or maybe build a workflow myself. Did you use Javascript or Applescript?
vitor Posted June 21, 2017 Posted June 21, 2017 1 hour ago, Dynamitleo said: Did you use Javascript or Applescript? Neither. I probably just threw a bash mv in there.
PopSquirrel Posted June 22, 2017 Author Posted June 22, 2017 @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
pontus Posted August 14, 2017 Posted August 14, 2017 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?
PopSquirrel Posted August 14, 2017 Author Posted August 14, 2017 @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.
PopSquirrel Posted August 14, 2017 Author Posted August 14, 2017 @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!
pontus Posted August 14, 2017 Posted August 14, 2017 @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.
pontus Posted August 15, 2017 Posted August 15, 2017 Check out the workflow here: https://www.dropbox.com/s/ctqy5m5d35p5obf/Open in Finder Tab Pontus.alfredworkflow?dl=0 I realise now that what I probably should do is a workflow that can imitate Alfreds default File Search behaviour and adds this functionality..
kenanmike Posted April 9, 2022 Posted April 9, 2022 On 8/15/2017 at 10:25 AM, pontus said: Check out the workflow here: https://www.dropbox.com/s/ctqy5m5d35p5obf/Open in Finder Tab Pontus.alfredworkflow?dl=0 I realise now that what I probably should do is a workflow that can imitate Alfreds default File Search behaviour and adds this functionality.. Hi @pontus, looks like the file is now deleted. Can you possibly share it again?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now