Shell Script works on one Mac, but gives "no such file or directory" on another

I have a macro, below, which as of last night was working perfectly on my MacBook. It creates a daily note with the format similar to, or, if such a note already exists, opens that note and gets it ready for me to start typing on a new line. This is in a folder indexed by DEVONthink (previously an Obsidian folder).

On a second Mac, I get an error when running the Shell Script step. The error is "No such file or directory", with respect to the Shell Script step. My wild guess after searching the last 30 minutes or so here is this has something to do with setting a Path in Shell Scripts, but that Wiki entry is beyond my ability to understand, unfortunately ("out of the box" Keyboard Maestro actions work for about 99% of what I do, without scripting).

I guess another possibility is that my macro didn't sync fully from the other machine, but I don't think that's it.

Is this something easily fixable by a non-programmer? Thank you for any help!

Here is the macro:

Assuming your short username is evan on both Macs, then ... I don't think you have the filePath variable structured properly.

In Terminal, the ~ is a shortcut pointing at your home folder (/Users/evan). The way you have the filePath written, it would expand to:


Try just setting it like this:


That should work, unless I'm not seeing some other issue.


Thank you for the reply. I made that change (which, if I'm looking at it correctly, moves the forward slash from just before the leading quote to after it) and get the same error. The odd thing is that the log in both instances says the same thing, and says that a file or directory doesn't exist, when in fact it does:

2023-12-11 14:07:53 Execute a Shell Script failed with script error: text-script: line 4: ~/Users/evan/Obsidian/KBG/@Daily_notes/ No such file or directory. Macro “Go to DEVONthink Daily Note, ready to enter copy” cancelled (while executing Execute Shell Script).

Here is a screenshot of the path of the file from Finder info pane:


(Note that in both the Macro in the initial post, the console log, and this screenshot, I've deleted my last name off off "evan", but they all contain that and otherwise match, as best I can tell)

Please get rid of the ~, as that's what's causing the error:


There is no such path, as I explained in the first reply, that will lead to a double /Users/evan entry. Just make it like this:



Oh wait, your last name is part of your username? You need this for filePath:


Whatever name shows up on your home folder in Finder is what you need there.


Removing the tilde got rid of the error, thank you! I'm running on fumes today, so my eyes jumped right to the later part of your first reply, and I'm embarrassed to say I missed that part.

Anyway, all is good now (the macro still needs some tweaks, but that was the first hurdle). I really appreciate the help.

No problem, glad to help! Click the "Solution" button so the forum marks this one resolved.


Thanks, I marked one as the Solution.

Perhaps I should start a new topic, but now I'm getting a really strange behavior where after the macro runs, all looks great (the note opens and puts "# [[" on a new line, per the last step of the macros) I sit back and smile, but then suddenly all the text in my note disappears and is replaced by the words "YourCommand", which is the same language in the last line of the Shell Script.

(Since posting the macro in the first post, I've since added a command to bring DEVONthink to the foreground, and a few keystroke commands to jump to the end of the file, but I don't think that would be the cause of this)

Can you please post the whole macro?


Actually, strike that, I don't need to see the macro. The problem is here:

echo "YourCommand" > "$filePath"

What that does is the following: It prints the text YourCommand, and then redirects it (the > sign) to the file named in the $filePath variable, hence overwriting anything that was there. I believe this macro was intended (maybe?) to create a new note, and load it with the text "YourCommand," though I'm not sure why anyone would want that.

If you just want to open the note, I think you'd want the last line (replacing the echo one) to say:

open "$filePath"

That will open the .md file in whatever default application is set to handle them, hopefully DEVONthink.


1 Like

Thanks. The more I'm digging into this, the more I think I either overwrote my final macro yesterday, or had an issue with sync (probably the former), because I'm also realizing that some other actions in the macro are missing, too.