Windows xcopy: Difference between revisions

 
(2 intermediate revisions by the same user not shown)
Line 35: Line 35:
xcopy /y "c:\Windows\notepad.exe" "c:\Program Files\notepad.exe"
xcopy /y "c:\Windows\notepad.exe" "c:\Program Files\notepad.exe"
</pre>
</pre>
== 錯誤訊息: 是否指定目標檔案,名稱或目標目錄名稱 (F = 檔案,D = 目錄)? ==
輸入命令的例子:
<pre>
xcopy /y "c:\source\abc.gz" "c:\target\def.gz"
出現訊息:
def.gz 是否指定目標檔案
名稱或目標目錄名稱
(F = 檔案,D = 目錄)?
</pre>
原因: 例子中的 c:\target\ 資料夾並不存在。如果選擇
* (1) F = 檔案,會建立 c:\target 資料夾,並且複製檔案到 c:\target\def.gz
* (2) D = 目錄,會建立 c:\target\def.gz\ 資料夾,並且複製檔案到 c:\target\def.gz\abc.gz
解決方式: 參考資料 [http://jdev.tw/blog/4334/xcopy-with-echo xcopy使用技巧 | 簡睿隨筆 | 學習過程的紀錄與備忘]
<pre>
# 自動輸入 F  (檔案)
echo F | xcopy /y "c:\source\abc.gz" "c:\target\def.gz"
# 自動輸入 D  (目錄)
echo D | xcopy /y "c:\source\abc.gz" "c:\target\def.gz"
</pre>
相關資料
* [http://superuser.com/questions/817586/xcopy-not-creating-source-folder-on-target-drive Xcopy not creating source folder on target drive - Super User]


[[Category:Windows]]
[[Category:Windows]]