Can't execute Automator action

I am a complete newcomer to KM so this is likely a dumb question…

I have a very simple automator workflow to move a file that I want to invoke by a KM macro (I am just practicing) . The automator workflow runs fine within Automator but when using KM to execute it, it hangs before completing the first step - that is the spinning cog wheel that KM shows in the menu bar says it is at the first step only.

My super simple steps are these:

I'd be grateful for any advice.

More generally, I cannot see how to work with KM using a file I have selected with the mouse since all file related actions seem to need a filepath spec - which is how I ended up trying the Automator thing.

Hey Chris,

Look here:

I'll post more later when I have time.

-Chris

Hey Chris,

Automator is gnarly and to be avoided unless as is occasionally true it brings something otherwise unavailable to the party.

Moving files in the Finder is a very simple application of collections in Keyboard Maestro.

A collection is essentially just a text-list of items.

Finder-Selection { Move Selected Items to Folder }.kmmacros.zip (952 Bytes)

You don't need to fix-the-selection-bug unless you're OSX system is between Snow Leopard and Mavericks.

When you drag & drop (or use the selection dialog) to insert a destination directory something like this will be inserted:

/Users/chris/test_directory/KM_MOVE_TEST

I do not like this convention for two reasons:

A) It's an absolute path.

B) There's no trailing slash on it to confirm for me it is definitely a directory and not a file.

I prefer to use this notation:

~/test_directory/KM_MOVE_TEST/

'~/' means your home directory.

This is a relative path that will survive changes in hard drive names, users, etc. It's good general practice to use this notation when the item is in fact within your home directory structure.

So for instance my Public Dropbox directory would be:

~/Dropbox/Public/

Now. Let's do the same thing with AppleScript.

set publicDbDir to alias ((path to home folder as text) & "Dropbox:Public:")
tell application "Finder"
  set fSel to selection as alias list
  if fSel ≠ {} then
    move fSel to publicDbDir with replacing
  end if
end tell

One thing to keep in mind is that KM will not overwrite any existing files, so if you want to replace something you have to use something like the AppleScript with replacing or turn to the shell.

-Chris

1 Like

Chris,
This is enormously helpful, thank you very much indeed. No doubt I’ll have other equally basic questions in due course and it is great to know that people like you are around to help.

Chris

I’d like to add my appreciation for Chris Stone and his activity on this discussion board. Chris, you have made me much more aware of the possibilities of marrying KM with Automator and with Terminal scripts. I must admit that I haven’t yet had the courage to try one, but I will. I will. I will.

1 Like