访问名为 "home" 的卷中的文件

access a file in a volume named "home"

我的 NAS 有一个名为“home”的共享点,安装在 Os X (Big Sur) 这个 applescript 揭示了一个错误。系统希望它是“/System/Volumes/Data/home”而不是“/Volumes/home/”。

为了测试,我写了一个名为“dummy.txt”的文本文件(里面有“hello world”)和运行这些行:

get POSIX file "/Volumes/home/dummy.txt" -- returns the file object as follows
--> document file "dummy.txt" of disk "home" 
-- or --> file "home:dummy.txt"
-- or --> "file:///Volumes/home/dummy.txt"

do shell script "cat" & space & quoted form of "/Volumes/home/dummy.txt"
--> "hello world"

get file "home:dummy.txt"
--> ERROR

do shell script "cat" & space & quoted form of POSIX path of "home:dummy.txt"
--> ERROR : no such file or directory

get POSIX path of "home:dummy.txt"
--> "/System/Volumes/Data/home/dummy.txt"

有解决办法吗?

将 HFS 路径强制转换为 POSIX 路径时,磁盘名称 home 与启动磁盘顶层的不可见文件夹 home 冲突。

要寻址外部卷,请始终使用语法

get POSIX file "/Volumes/home/dummy.txt" 

do shell script "cat" & space & quoted form of "/Volumes/home/dummy.txt"