Running macro on icloud folder returns no such file or directory?


#1

Hi all,

I couldn't find any clue why the following would not work, hence I finally made the switch from being a silent reader and signed up… :wave:

I'm trying to run the following macro on my iA writer folder within icloud. When using it with a local or dropbox path everything works fine — if I use ~/Library/Mobile Documents/27N4MQEA55~pro~writer/Documents/ I get a "No such file or directory." error even though I can manually cd into the above directory and run the ls command. Do you guys have any hints or workaround?

cd ~/Dropbox/zettelkasten
ls -t | sed -e 's/.[^.]*$//'

which will be inserted into: 
[[%Variable%tmp%]]

In case anyone wonders: the macro is needed in conjunction with the archive to provide a typeahead functionality in order to link to notes more easily.

Thanks in advance for any hint :slight_smile:


#2

Do the commands work in the Terminal? If you are in the Terminal and run the commands:

cd ~/Library/Mobile\ Documents/27N4MQEA55~pro~writer/Documents/
ls -l

What do you get?

Are you making sure to quote the space in Mobile Documents, and not quote the ~?


#3

Thanks @peternlewis!

…it must have been the space in Mobile that caused trouble. I could have sworn I had checked it when trying but obviously must haved missed something. Now it works like a charm. Thanks again :slight_smile:


#4

I’m having similar problems with the exact same script.

Can you clarify exactly whether quotes need to be enclosing the path when there is a space in the path, within the KM script area?

I thought I had it working, but then grep ended up running away with my processor and bringing the machine down, so I must have something wrong.

The problem has only emerged with this script after I moved its operation out of a Dropbox folder and into an iCloud one.


#5

Hey Andrew,

If you're running from an Execute a Shell Script action then spaces must either be quoted or escaped.

Quoted:

You can quote just the portion of the path that has spaces in it, but I tend to quote the whole path:

Regular Posix Path:

ls '/Applications/Applications_Chris/Audio Visual Apps'

Tilde-based path:

ls ~/'Library/Mobile Documents/'

ls ~/'Library/Mobile Documents/8HSTZV64A5~com~acqualia~soulver/Documents'

** Note that the ~/ prefix MUST NOT be contained in the quotes!

Escaped:

ls ~/Library/Mobile\ Documents/

ls ~/Library/Mobile\ Documents/8HSTZV64A5~com~acqualia~soulver/Documents

The wiki is empty right now during the run-up to Keyboard Maestro 9, but you can normally find more information here:

Shell Scripting

-Chris