Wilbuck Posted April 12, 2020 Share Posted April 12, 2020 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
deanishe Posted April 12, 2020 Share Posted April 12, 2020 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" strajk 1 Link to comment
Wilbuck Posted April 12, 2020 Author Share Posted April 12, 2020 This worked perfectly. Thank you! A really amazing app that you guys have created. Thanks again. Link to comment
Textdriven Posted December 9, 2021 Share Posted December 9, 2021 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
deanishe Posted December 9, 2021 Share Posted December 9, 2021 1 hour ago, Textdriven said: But what do i append to the path to make sure it highlights my moved file? You pass in the path of the file you want to reveal in Finder. Link to comment
Textdriven Posted December 9, 2021 Share Posted December 9, 2021 I'm dumb and don't program myself, I just hack. 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. Link to comment
deanishe Posted December 9, 2021 Share Posted December 9, 2021 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
Textdriven Posted December 10, 2021 Share Posted December 10, 2021 Great that works perfectly. Thank you. Link to comment
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