Opening a file in Documents folder that is managed by iCloud

I’m having difficulty with a script that has worked without fail for years. It opens several files in a specific subfolder of the Documents folder, with BBEdit. (A similar script searches the same set of files.) The problem began when I enabled iCloud’s ability to offload my Documents folder from my SSD to iCloud. Apparently, it moves individual files from iCloud back to the SSD if I am using them frequently.

I have attempted to construct “try” blocks to attempt to locate the files first in iCloud, and, if that fails, to revert to ~/User/xxxx/Documents. But now nothing seems to work.

Is there any sneaky way in AppleScript to obtain the path to the Documents folder that is in iCloud, similar to “path to documents folder”?

Any other suggestions on a better way to do what I am trying to do?

I am thinking of simply moving these four files to a folder on my local SSD and accessing them in that stable location. That may be the easiest way, but I’m geek enough to wonder if there is a more interesting way to solve the problem. :slight_smile:

Model: Macbook Air 2012
Browser: Safari 537.36
Operating System: Mac OS X (10.13 Developer Beta 3)

If I’m not mistaken the real location on the Mac is:
/Users/username/Library/Mobile\ Documents/com~apple~CloudDocs/Documents/