Jump to content
raguay.customct

Copy/Move To and Alfred Browser Workflows

Recommended Posts

Hi,

 

Just uploaded two new (old for me) workflows that I find very useful and thought someone else might like them. They are:

 

Copy/Move To Workflow

This workflow starts with a "Add Directory to Copy/Move locations..." File Action to create a list of directories to use as targets for a copy/move operation. If actioned on a file, the directory of the file is saved.

Once you have a list, you can use "copy to..." or "move to..." file actions to move or copy files to a previously saved directory.

The keyword "cm:fav" is used to view saved directories, remove one, go to one in Alfred Browser, open in Finder, or go to in terminal/iTerm depending on your terminal preset in Alfred.

 

Alfred Browser Toolbox

 
Keywords
 
ff
 
It is a way to lookup a folding in the Alfred browser or in Finder. Very handy.
 
ab:newfile
 
Creates a new file in the directory of the topmost Finder, Commander One, or Path Finder window.
 
ab:newdir
 
Creates a new directory in the directory of the topmost Finder, Commander One, or Path Finder window.
 
ab:open
 
Opens the URL, URI, or file given using the Mac OS X open terminal command. This has a hot key as well to open the current selection with "open".  This works with Finder, Path Finder, and Commander One.
 
ab:pdf
 
This is a file filter for PDF files. I have many and this really makes finding them easy.
 

ab:cparent   

 

This command will get the currently selected file in Finder, Path Finder, or Commander One and copy it to the parent directory. Works on files or directories. This has a Hotkey as well.

 

ab:mparent   

 

This command will get the currently selected file in Finder, Path Finder, or Commander One and move it to the parent directory. Works on files or directories. This has a Hotkey as well.

 

ab:cfile      

 

This command will copy the contents of the file to the clipboard. You need to be sure it is a text file. This has a Hotkey as well.

 
Alfred Browser Actions
 
Get File Name
 
This gets the name of the file selected in Alfred Browser and puts it into the clipboard.
 
Get File Size
 
This gets the file size of the file selected in the Alfred Browser and puts it into the clipboard.
 
Create a File
 
Simply creates a file in the directory this file action is ran on. It will ask you for the name and then create it.
 
Create a Directory
 
Same as "Create a File", but creates a directory instead.
 
Copy Relative Home Path
 
This file action calculates the relative path from the user’s home directory and copies it to the clipboard.
 
Paste Relative Home Path
 
This file action copies the absolute path to the clipboard. It will then paste the relative path to the topmost application.
 
Copy Absolute Path
 
This file action copies the absolute path to the clipboard.
 
Paste Absolute Path
 
This file action calculates the relative path from the user’s home directory and copies it to the clipboard. It will then paste the relative path to the topmost application.
 

Copy/Move to Parent Directory

 

These two actions will copy/move the selected file to the parent directory.

 

Copy File Contents to Pasteboard

 

This action will copy the contents of the file to the pasteboard.

 

NOTE: Currently this requires OS X 10.10 because I am using JavaScript for Automation that is only in 10.10. Sorry!

 

Version: 1.5

Date:      12/04/2015

 

You can get them from my Github account: https://github.com/raguay/MyAlfred

or Packal:

 

http://www.packal.org/workflow/copymove

http://www.packal.org/workflow/alfred-browser-toolbox

Edited by raguay.customct

Share this post


Link to post

It looks like an awesome workflow. Unfortunately, I couldn't make it work.

 

Got the error: 

Starting debug for 'Files - Copy/Move to'

[INFO: alfred.workflow.trigger.action] Processing output 'alfred.workflow.action.script' with arg '(
    "NAME_OF_A_FILE_LOCATED_IN_THE_DOWNLOADS_FOLDER.pdf"
)'
[ERROR: alfred.workflow.action.script] Code 0: GetName.scpt: script error -1762.  Couldn't get error text because of error -1700.
[INFO: alfred.workflow.action.script] Processing output 'alfred.workflow.output.notification' with arg 'Just added: 
'

Downloaded from packal (v1.1)

OSX 10.9.5.

Share this post


Link to post

I guess I should of mentioned that it will only work in OS X 10.10 Yosemite. It is making use of JavaScript for Automation instead of AppleScript. Therefore, you would need to upgrade to 10.10. Sorry. I will look into making it backwards compatible.

Share this post


Link to post

I tried the workflow because on packal it says it is compatible with previous versions of OSX (ie 10.9)... 

I planned on installing Yosemite this week so, it is not such a big deal  :)

Share this post


Link to post

#feedback 

 

Apparently, the workflow doesn't like , or ( ) or [ ] in file names :)  / Exotic files types like .chm files.

 

I couldn't copy one file with an exotic name. It included [ ] -> Error: No such file or directory.

 

I couldn't move the .chm file -> Error: No such file or directory

 

Very useful workflow. Thank for sharing. 

Edited by politicus

Share this post


Link to post

Hi, I can not reproduce your error. Is it the copy or move function? Is it the source or destination? All of my destinations have spaces and parenthesis and true files should not make a difference. But, files that are really directories will not work since I am just using the standard unix cp command.

 

I will experiment with making the cp function recursive and see if that helps. Update soon...

Share this post


Link to post

I assume your error was with copying. The mv command is already recursive and should work with files that are really folders. Now, both are recursive and can be used on folders. Just uploaded update.

Share this post


Link to post

@raguay.customct 

 

After I installed the latest version of the workflow, some of the "saved destination directories" ( = directories I added to to Copy/Move locations...) of the previously installed version of the workflow were still there. Looks like they are cached somewhere and not purged yet.

 

The delete command of the cm:fav command didn't help me delete them as it threw an error message "strpos(): Empty needle i...".

 

I didn't log out from OS X Yosemite. 

Share this post


Link to post

Just fixed another bug that stored files and not directories. I also added the ability to open a favorite directory in a terminal program. It uses the Alfred Terminal command that defaults to Terminal.app, but can be made to use iTerm in the Alfred configurations.

Share this post


Link to post

Tried the 1.4 version (from Packal).

 

1°) The cm:reset action is working like a charm.

 

2°) I couldn't perform a delete action on a directory list item. In Alfred's debug mode, I got the error: 

Starting debug for 'Files Copy/Move to'

[ERROR: alfred.workflow.action.script] Code 0: 2015-01-05 11:02:10.482 osascript[5157:307793] warning: failed to get scripting definition from /usr/bin/osascript; it may not be scriptable.

Share this post


Link to post

Okay, I found the bug in the copy/move for removing the directory from the list. The php strpos function did not do what I expected. I am now using strcmp and it seems to be working better. Not sure what your error message is coming from as that section of code doesn't use osascript. It is updated on Packal and my GitHub. Please redownload and give it a try.

Edited by raguay.customct

Share this post


Link to post

Perhaps I am missing something, how do I choose what directories I can copy/save to?

 

When you are in the Alfred prompt, go to the Alfred Browser by typing in a path (ie: ~ for home). Move around to the directory you want to mark as a favorate and press right arrow. That brings up a list of possible actions. Type "Add" and select the "Add Directory to Copy/Move locations". Now, when you use the copy/move functions, that directory will show up as a possible destination.

Share this post


Link to post

A feature request for you  :)

 

A File action that would let me move the files I selected to its parent folder (without having to specify the name of the current folder). 

 

For more information on what I am looking for: here.

 

Thank you.

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