我一直在尝试创建一个将选定文件复制到预定目录的简单应用程序,只有在shell脚本中设置时该变量才起作用。我想知道是否有办法用短语复制或移动命令以使其生效。脚本如下。
set filepath to POSIX path of (choose file with prompt "Chose your file")
delay
do shell script "cp " & filepath & " ~/Library/Application Support/"
答案 0 :(得分:1)
它不起作用,因为必须转义路径中的空格字符,最可靠的方法是使用quoted form of
。
path to application support folder from user domain
是当前用户的应用程序支持文件夹的相对路径。
set applicationSupportFolder to POSIX path of (path to application support folder from user domain)
set filepath to POSIX path of (choose file with prompt "Chose your file")
do shell script "cp " & quoted form of filepath & space & quoted form of applicationSupportFolder