[英]How to copy and replace files in Apple Automator, while retaining folder structure?
I have two folders that have similar sub-folder structures. 我有两个文件夹具有相似的子文件夹结构。 I need to copy, not sync, the files from one in to the other, replace any existing files if they are present in the destination folder, and keep the sub-folder hierarchy.
我需要将文件从一个文件复制到另一个文件,而不是进行同步,如果目标文件夹中存在文件,请替换它们,并保留子文件夹的层次结构。
For example, starting with this: 例如,从此开始:
/source_folder/stuff/sub_one/file1.txt
/source_folder/stuff/sub_one/file2.txt
/source_folder/stuff/sub_two/file3.txt
/destination_folder/stuff/sub_one/file1.txt
/destination_folder/stuff/sub_one/file9.txt
/destination_folder/stuff/sub_three/file4.txt
After copying: 复制后:
/source_folder/stuff/sub_one/file1.txt
/source_folder/stuff/sub_one/file2.txt
/source_folder/stuff/sub_two/file3.txt
/destination_folder/stuff/sub_one/file1.txt (replaced by copy in source_folder)
/destination_folder/stuff/sub_one/file2.txt (added from copy in source_folder)
/destination_folder/stuff/sub_one/file9.txt
/destination_folder/stuff/sub_two/file3.txt (added from copy in source_folder)
/destination_folder/stuff/sub_three/file4.txt
I've created the following Auotmator project, but the files are all copied to the root of the destination folder. 我创建了以下Auotmator项目,但是文件全部复制到了目标文件夹的根目录。
Any recommendations on how to accomplish this in Apple Automator? 关于如何在Apple Automator中完成此操作的任何建议?
I found the following works. 我发现以下作品。
Add a "Run AppleScript" action in Automator, then add the following script: 在Automator中添加“运行AppleScript”操作,然后添加以下脚本:
on run {input, parameters}
tell application "Finder"
set source to choose folder with prompt "Choose source folder"
set destination to choose folder with prompt "Choose destination folder"
do shell script "rsync -rI " & POSIX path of source & space & POSIX path of destination
end tell
return input
end run
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.