【发布时间】:2020-07-24 04:40:42
【问题描述】:
我正在尝试编写一个 AppleScript,它将简单地将内容(文件夹和文件)从指定的源文件夹复制到指定的目标文件夹。目前我的脚本运行但只复制一个文件,我不知道如何让它复制文件夹中的所有文件。
这是我的脚本:
set sourceFolder to (POSIX file "/Users/benny/Desktop/Projects/Source/Project1") as alias
set destinationFolder to (POSIX file "/Users/benny/Documents/Masters/Project1") as alias
tell application "System Events"
set availableSourceFiles to every file of sourceFolder whose visible is true
set filesOfTargetFolder to files of destinationFolder whose visible is true
end tell
-- if no more source file is available, quit this script
if (count of availableSourceFiles) = 0 then
quit
end if
set sourceFile to (first item of availableSourceFiles) as alias
-- use the Finder to copy the file
tell application "Finder"
-- duplicate the file to the target folder
duplicate sourceFile to destinationFolder
end tell
我假设我需要包含一个 for each 类型循环,但在这里无法获得正确的语法。很多年没有写过 AppleScript,所以试着记住它是如何工作的。
【问题讨论】:
标签: applescript