我尝试在路径名字符串中连接变量以使此脚本更有效。 这是我到目前为止的代码。但我似乎无法找到所需的正确语法,以便在字符串中设置变量。
set vserver to POSIX file "/Volumes/johndoe"
set user to "johndoe" as string
set source to POSIX file "/Users/johndoe/Documents"
tell application "Finder"
duplicate source to vserver with replacing
end tell
我希望johndoe被变量用户替换,以使代码在将来更易于维护。我的最终目标是能够将多个家庭文件夹(包括:电影,图片,文档等)复制到共享服务器上。
我试过这个
"/Users/" & user & "/Desktop"
但我收到了这个错误:
" Finder收到错误:处理程序无法处理此类对象。" 号码-10010
答案 0 :(得分:0)
不是硬编码,而是可以像这样获得桌面路径:
set source to path to desktop