我的老板要我写一个带有文件的AppleScript,在文本脚本中用硬编码路径指定,将文件从Finder中的一个位置复制到另一个位置(在此过程中为其提供一个新文件名) )。
这是我的想法
tell application "Finder"
copy "/blah/blahblah/
save as "blah blah2" /blah/blah/blah
end tell
答案 0 :(得分:0)
Copy
是AppleScript命令,不是finder命令,
copy 1 to a
会将值1复制到变量a
您要复制文件的命令是duplicate
。
set fileToCopy to "DiskName:Users:shortname:Downloads:document.pdf"
set targetFolder to "DiskName:Users:shortname:Desktop:"
tell application "Finder" to duplicate fileToCopy to folder targetFolder
答案 1 :(得分:0)
感谢您的支持!
任何提出这个问题的人都是我最终的结果
set desktopFolder to path to desktop as text
set thefile to desktopFolder & "lol.html"
set DestinationPath to desktopFolder & "BLAH BLAH BLAH"
set destinationFilename to "ROFL2.txt"
with timeout of 60 seconds
tell application "Finder"
try
set theDupe to duplicate file thefile to folder DestinationPath
set name of theDupe to destinationFilename
on error
display dialog "A problem occurred duplicating the file. This may be because the file already exists!"
end try
end tell
end timeout