2015-12-08 70 views
0

我有兩個文件夾有相似的子文件夾結構。我需要將文件從一個文件複製到另一個文件中,如果它們出現在目標文件夾中,則替換所有現有的文件,並保留子文件夾層次結構。如何在保留文件夾結構的同時在Apple Automator中複製和替換文件?

例如,從這樣的:

/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 

複製後:

/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 

我創建了以下Auotmator項目,但文件都複製到目標文件夾的根目錄。

enter image description here

如何在蘋果的Automator做到這一點的任何建議?

+0

它看起來像調用「同步-RI」將解決這個問題。我正在繼續探索。 – TERACytE

回答

0

我發現了以下工作。

在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 
相關問題