How to retrieve path of file in iCloud?

I have a collection of PDFs stored in a directory in iCloud and I need to retrieve the link for them from within Finder. I am attempting to use AppleScript and referencing this post and some other ideas from the web, I am trying to use the following, but it fails with "Can't make alias":

tell application "Finder" 
	set sourceFolder to target of front window as alias
	display dialog sourceFolder
end tell

My intent is to embed the PDF in a Markdown file using the full filesystem path syntax, e.g. ![[file:///path/to/file.pdf]]. What would be a good way to approach this?

I think there may be bracket and type conversion glitches in the draft you have there.

Does this seems to work ?

tell application "Finder"
    set sourceFolder to POSIX path of ((target of front window) as alias)
end tell

Incidentally the normal markdown markup for a link would have the form:

[label](url)

the format you are showing is a wiki reference, rather than a markdown link, but perhaps that's what you need ?

1 Like