Should be a simple Finder move

This just has me stumped, even after looking at forum examples. I thought it should be easy: select a file(s) in the finder and move them to the desktop, or a specified folder. I used the desktop in this example as part of my troubleshooting. Once I get it to work, I will replace ~/Desktop with ~/Desktop/keepers. The folder keepers exists.

The macro fails every time with this notification:
Action failed with Error Domain=NSCocoaErrorDomainCode=4 ""thefilename.jpg...

Here is a screenshot of my macro. It looks to me exactly like the forum example:

Thanks.:slight_smile:

That should work. It does on my system. I don’t know what the error message means.

Can you please post the entire error msg?
If you can't see more, then do one of the following:

  • Open Notification center and view the msg
  • Open the KM Engine log

GoTo menu Help > Open Logs Folder, or just open this file:
~/Library/Logs/Keyboard Maestro/Engine.log

You might also do a Google search on "mac Error Domain=NSCocoaErrorDomainCode=4"

From a quick review, it looks like you may be trying to either move the file FROM a folder, or TO a folder that you do NOT have write permission.

This has saved me many times! But I never remember where it is! So... :wink:

Your litaral macro works also fine here, on OS 10.13.2 with iCloud Documents & Desktop Sync enabled (which was my primary concern).

Thanks you for your suggestions.

Here is the complete error message from the engine log:

2018-01-15 10:46:13 Execute macro “move the finder selection to Desktop/keepers” from trigger The Status Menu
2018-01-15 10:46:13 Move file /Users/russell/Desktop/Test file.docx
failed with Error Domain=NSCocoaErrorDomain Code=4 ““Test file.docx
” couldn’t be moved to “keepers” because either the former doesn’t exist, or the folder containing the latter doesn’t exist.” UserInfo={NSSourceFilePathErrorKey=/Users/russell/Desktop/Test file.docx
, NSUserStringVariant=(
Move
), NSDestinationFilePath=/Users/russell/Desktop/keepers/Test file.docx
, NSFilePath=/Users/russell/Desktop/Test file.docx
, NSUnderlyingError=0x60000065f0b0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}}

I thought about file and directory ownership and permissions since my original test was with a file created by someone else and sent to me in zip archive. “Test file.docx” is newly created, by me, on my desktop. Just for a sanity check, I also created a new destination folder. No go.

I did search up the “NSCocoaErrorDomain Code=4” and “NSPOSIXErrorDomain Code=2”. All the citations I read referred to iOS simulators and application development. Perhaps I didn’t delve deep enough into pages 3 to N.

Now that I see the POSIX error, I’m thinking this may be attributable to macOS 10.13.3 Beta. Sorry, I should have thought of that when writing my original post, but I didn’t have the entire error message. Oh well… The risks of using beta software.

I did manage to make an Automator service that accomplishes what I want. I will test this again and report my results here when macOS 10.13.3 is released and I am no longer running a beta OS.

If I look closely at your posted log entry I see that there are always line breaks after Test file.docx, for example

“Test file.docx
” couldn’t be moved

Normally it would look like this:

“Test file.docx” couldn’t be moved

This could have happened while pasting the text into the forum editor, but I am not sure if this really was the case, because there is a line break exactly after each of the 5 occurences of Test file.docx.

Furthermore I can reproduce your exact log entry by using this macro:

Note the added explicit line break after the variable.

The resulting log entry is exactly as yours:

2018-01-16 18:48:24 Move file /Users/tom/Desktop/Test file.docx
 failed with Error Domain=NSCocoaErrorDomain Code=4 "“Test file.docx
” couldn’t be moved to “keepers” because either the former doesn’t exist, or the folder containing the latter doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/tom/Desktop/Test file.docx
, NSUserStringVariant=(
    Move
), NSDestinationFilePath=/Users/tom/Desktop/keepers/Test file.docx
, NSFilePath=/Users/tom/Desktop/Test file.docx
, NSUnderlyingError=0x6080002418c0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

You see the line breaks after each Test file.docx ?

This makes me think that you may have some kind of stray character after the variable name in the move action. This might be any newline character or maybe another invisible character that gets interpreted as newline.

Or you have an invisible character at the end of the file name of the real file? (Unlikely.)


To make things clearer you should post the log entry again, formatted as code block. So we can see if there is really a line break after each Test file.docx.

You make a fenced code block like this:

```bash
<your pasted log entry here>
```

Or simply try and create a new macro by typing all the content (variable names), not by pasting.

###PS:

Here my version of the macro that works for me:

[test] Move file to Desktop.kmmacros (3.1 KB)

1 Like

All very interesting, thanks. New destination folder. New test file. Both carefully typed. Opened the log file with Console this time rather than BBEdit, just in case BBEdit was adding the line break.

Same error and the log looks the same. The line breaks appear in the Console and BBEdit windows, not just in this forum message.

2018-01-16 10:48:29 Execute macro “move the finder selection to Desktop/keeper3” from trigger The Status Menu
2018-01-16 10:48:29 Move file /Users/russell/Desktop/testfile3.txt
 failed with Error Domain=NSCocoaErrorDomain Code=4 "“testfile3.txt
” couldn’t be moved to “keeper3” because either the former doesn’t exist, or the folder containing the latter doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/russell/Desktop/testfile3.txt
, NSUserStringVariant=(
    Move
), NSDestinationFilePath=/Users/russell/Desktop/keeper3/testfile3.txt
, NSFilePath=/Users/russell/Desktop/testfile3.txt
, NSUnderlyingError=0x60800065c770 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2018-01-16 10:48:29 Move file /Users/russell/Desktop/testfile3.txt
 failed with Error Domain=NSCocoaErrorDomain Code=4 "“testfile3.txt
” couldn’t be moved to “keeper3” because either the former doesn’t exist, or the folder containing the latter doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/russell/Desktop/testfile3.txt
, NSUserStringVariant=(
    Move
), NSDestinationFilePath=/Users/russell/Desktop/keeper3/testfile3.txt
, NSFilePath=/Users/russell/Desktop/testfile3.txt
, NSUnderlyingError=0x60800065c770 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} In macro “move the finder selection to Desktop/keeper3” (while executing Move or Rename File “%Variable%Path%
”).
2018-01-16 10:48:29 Move file /Users/russell/Desktop/testfile3.txt
 failed with Error Domain=NSCocoaErrorDomain Code=4 "“testfile3.txt
” couldn’t be moved to “keeper3” because either the former doesn’t exist, or the folder containing the latter doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/russell/Desktop/testfile3.txt
, NSUserStringVariant=(
    Move
), NSDestinationFilePath=/Users/russell/Desktop/keeper3/testfile3.txt
, NSFilePath=/Users/russell/Desktop/testfile3.txt
, NSUnderlyingError=0x60800065c770 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2018-01-16 10:48:29 Move file /Users/russell/Desktop/testfile3.txt
 failed with Error Domain=NSCocoaErrorDomain Code=4 "“testfile3.txt
” couldn’t be moved to “keeper3” because either the former doesn’t exist, or the folder containing the latter doesn’t exist." UserInfo={NSSourceFilePathErrorKey=/Users/russell/Desktop/testfile3.txt
, NSUserStringVariant=(
    Move
), NSDestinationFilePath=/Users/russell/Desktop/keeper3/testfile3.txt
, NSFilePath=/Users/russell/Desktop/testfile3.txt
, NSUnderlyingError=0x60800065c770 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}} In macro “move the finder selection to Desktop/keeper3” (while executing Move or Rename File “%Variable%Path%
”).

Your test macro worked as designed. I then altered my macro (disabled the old step and added a new step). It worked as designed. comparing the two, I see that in the name of the old step, the second " is missing from the end of the name, but not in the new step:

If I edit the name of that step, the second " is there, but is invisible again once I change focus without editing.

I edited the step name to be just nonsense text and the macro works.

Bizarre. Now that the name of the step has been edited, the error cannot be replicated.

Any insights?

Thanks for your help.

Yep, since for the action name KM supposedly just grabs the content of the text field and wraps it with quotes, this would be another indicator that there is some invisible line-breaking stuff at the end.
(I noticed only now that this was already visible in your very first screenshot.)

But it is hard to find an explication for this:

  • If I understand correctly you have edited only the name of the action, not the content of the Move text field?

  • What happens when you reset the name of the action? (Delete all chars in the name field and hit Return.)

  • With the non-working action, have you examined the content of the Move text field?

    • (Select all, paste it to BBEdit, turn on Show Invisibles, and see if there is any trailing character/newline.)
  • Have you examined the XML file in a text editor? (That is, the exported kmmacros or kmactions file.)

  • Or, if you still have the non-functional macro around, can you export and upload it? (The macro, not a screenshot.)


PS:

You can easily add a line break after the %Variable%Path% by pressing ⌥-Return. When you then press the Upwards Arrow the line break becomes entirely invisible in the field, but in the action name the closing quote mark is not displayed, since it is on the (hidden) second line.

But:

  • I guess you never have done this
  • I can not make it go away by editing the name of the action
1 Like

I re-traced my troubleshooting steps with a copy of the nonfunctioning macro. I found a CR or line break in the variable field. It was not obvious because the field is one line high. I’m guessing I typed return instead of tab when entering the variable and destination folder.

While troubleshooting, I must have altered both the variable field and the action name between tests. Very sloppy procedure.

Mystery solved.
Lesson learned.

Thank you for your help.

Yes, this seems likely.

But to enter a line break after the variable name you would have to press ⌥-Return (not only Return). See the Edit of my post above.

PS: Ctrl-Return seems to also produce a line break in the field.

Help ➤ Open Logs Folder will show you the Logs Folder containing the Editor.log and Engine.log

1 Like