AppleScript - 将文件夹从一个位置复制到另一个位置时排除某些文件
AppleScript - exclude certain files when duplicating a folder from one location to another
我有一个 AppleScript 可以将源文件夹的内容复制到目标文件夹。我现在需要为此添加一些条件逻辑,以便它从源文件夹中排除某些文件并且不会复制到所有 files/folders.
这是我当前的脚本:
set here to POSIX file "/Users/benny/Desktop/Projects/Source/Project1"
set there to POSIX file "/Users/benny/Documents/Masters"
tell application id "com.apple.Finder" to duplicate ¬
every item in the folder here to there
我想添加一些逻辑,使其不会跨这些文件进行复制:
Import.log
Recover.log
尚未尝试使语法在此处起作用,但到目前为止还无法弄清楚如何按文件名排除文件。
duplicate
命令被包装在try
语句中,因为如果[= there
中已存在 18=] 项 相同的 name。您可以取消注释 with replacing
并删除 try
语句 ,也就是说,如果替换现有的 item 没问题.
set here to POSIX file "/Users/benny/Desktop/Projects/Source/Project1"
set there to POSIX file "/Users/benny/Documents/Masters"
tell application id "com.apple.Finder"
set theseItems to a reference to ¬
(items whose name is not equal to "Import.log" and ¬
name is not equal to "Recover.log") of folder here
try
duplicate theseItems to there -- with replacing
end try
end tell
我有一个 AppleScript 可以将源文件夹的内容复制到目标文件夹。我现在需要为此添加一些条件逻辑,以便它从源文件夹中排除某些文件并且不会复制到所有 files/folders.
这是我当前的脚本:
set here to POSIX file "/Users/benny/Desktop/Projects/Source/Project1"
set there to POSIX file "/Users/benny/Documents/Masters"
tell application id "com.apple.Finder" to duplicate ¬
every item in the folder here to there
我想添加一些逻辑,使其不会跨这些文件进行复制:
Import.log
Recover.log
尚未尝试使语法在此处起作用,但到目前为止还无法弄清楚如何按文件名排除文件。
duplicate
命令被包装在try
语句中,因为如果[= there
中已存在 18=] 项 相同的 name。您可以取消注释 with replacing
并删除 try
语句 ,也就是说,如果替换现有的 item 没问题.
set here to POSIX file "/Users/benny/Desktop/Projects/Source/Project1"
set there to POSIX file "/Users/benny/Documents/Masters"
tell application id "com.apple.Finder"
set theseItems to a reference to ¬
(items whose name is not equal to "Import.log" and ¬
name is not equal to "Recover.log") of folder here
try
duplicate theseItems to there -- with replacing
end try
end tell