2015-02-09 147 views
-3

我的老板要求我写一个带文件的AppleScript,在文本脚本中用硬编码路径指定,将文件从Finder中的一个位置复制到另一个位置(给它进程中的新文件名)。使用新文件名复制文件

这是我的主意

tell application "Finder" 
    copy "/blah/blahblah/ 
    save as "blah blah2" /blah/blah/blah 
end tell 
+0

谷歌是你的朋友[https://discussions.apple.com/thread/2810276](https://discussions.apple.com/thread/2810276) – CRD 2015-02-09 21:58:01

回答

0

Copy是一个AppleScript命令没有取景器命令,

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 
+0

错误“Finder出现错误:无法将\”Macintosh HD:MacTech:Desktop:ROFL.txt \“放入类型项目中。”编号-1700从“Macintosh HD:MacTech:Desktop:ROFL.txt”到项目我尝试复制文件时出现此错误:( – 2015-02-10 20:09:56

0

感谢您的支持!

任何who'zle这是我结束了

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 
相关问题