需要複製帶有子資料夾的資料夾而不回答提示

需要複製帶有子資料夾的資料夾而不回答提示

我需要將資料夾 A 複製到資料夾 B,並且資料夾 A 有子資料夾。我試過 xcopy 和 copy 都卡住了。

C:\Users>xcopy  sushantg\A\* sushantg\B /s /e /h /T
Does sushantg\B specify a file name
or directory name on the target
(F = file, D = directory)?
Does sushantg\B specify a file name
or directory name on the target
(F = file, D = directory)?

答案1

您在這裡有兩個主要選擇:

第一個選項是新增/i參數。相關文字在文件如下:

如果來源是目錄或包含通配符且目標不存在,則 xcopy 假定目標指定目錄名稱並建立新目錄。然後,xcopy 將所有指定的檔案複製到新目錄中。預設情況下,xcopy 會提示​​您指定目標是檔案還是目錄。

另一種選擇是透過以反斜線結尾來指定目標是一個目錄,這將使程式碼如下所示:

xcopy  sushantg\A\* sushantg\B\ /s /e /h /T

(註 後面的反斜線B

目前我找不到此選項的任何相關文檔,但我在本地測試了它並解決了問題。

答案2

嘗試:

echo f | Xcopy /f /y sushantg\A\* sushantg\B /E /H

相關內容