Jump to content

Move file to specific folder


Recommended Posts

Thank you for assisting me in advance; i just purchased the powerpack.  I’m a newbie to Alfred, and after some searching haven’t been able to find the answer to my question ( i may have missed it). I would like to add a custom file action to “move a file to folder___”. I realize the “move to” option is  available, but i wanted to be able to quickly move a file to a specific folder.  I created a file action trigger as described  https://www.alfredapp.com/blog/tips-and-tricks/file-actions-from-alfred-or-finder/, but I’m not sure what output to add next or where to edit the path to send the file(s)?

 

thank you for your help! 

Link to comment

There are multiple specific ways to do it, but essentially you need to connect your "Move File to XYZ" File Action to a Run Script action and fill it with a script in the language of your choice to do the actual moving.

 

The simplest script would be to set Language to /bin/bash and paste the following in the Script box:

mv -n "$@" "/path/to/target/folder"

Or if you want to overwrite any existing files with the same names:

mv -f "$@" "/path/to/target/folder"

 

If you expect to change the target folder often, you can set a workflow/environment variable in the configuration sheet and use that in your script. So if you name the variable TARGET_FOLDER, your script would then be:

mv -n "$@" "$TARGET_FOLDER"

Or if you want to overwrite any existing files with the same names:

mv -f "$@" "$TARGET_FOLDER"

Link to comment
  • 1 year later...

Could i add to this question. I've successful done the above but when the action finishes i would also like to reveal the file in it's new location in finder.

 

I've got as far as opening the the target directory in finder with the "Reveal in finder" action. But what do i append to the path to make sure it highlights my moved file?

 

Link to comment
6 hours ago, Textdriven said:

I'll probably figure it out but I'm trying work out how to assign and pass the new path to the reveal in finder action to show the file at it's new location.


Well, that depends on what's immediately before the Reveal in Finder.

 

If it's the above shell script, add the line:

 

echo -n "${TARGET_FOLDER}/${1:t}"

 

Note: That's zsh-specific. It won't work with bash.

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