使用新文件名复制文件



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

这是我的想法

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

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

感谢您的反对票!

这就是我最终使用的原因

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

最新更新