Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Win7 64 位元 CMD 高效複製/刪除資料夾指令:xcopy 與 rd

編輯:Windows 7 系統介紹

複製資料夾:xcopy

將 F:\File 複製到 C:\File(含子目錄、隱藏檔、系統檔):

xcopy F:\File C:\File /E /H /K /Y
  • /E:複製子目錄(含空目錄)。
  • /H:包含隱藏與系統檔。
  • /K:保留唯讀屬性。
  • /Y:不提示覆蓋確認。
CMD 複製範例 xcopy 參數說明

刪除資料夾:rd / rmdir

del 無法刪除資料夾**,僅能刪除檔案。刪除資料夾需用 rd(或 rmdir)。

:: 刪除 D:\123 及其所有內容,不提示確認
rd /S /Q D:\123
  • /S:刪除樹狀結構(含所有子目錄與檔案)。
  • /Q:安靜模式,不提示確認(需搭配 /S)。

常見誤區

  • del /S /Q D:\123\*.* 僅刪除資料夾**內部的檔案**,資料夾本身仍保留。
  • rd D:\123 若資料夾非空會報錯「目錄不是空的」,必須加 /S。

進階技巧

  • 刪除超長路徑資料夾:rd /S /Q "\\?\D:\Very\Long\Path\Folder"。
  • 批次檔中使用變數:rd /S /Q "%TargetDir%"。
  • 搭配 for /d 批次刪除多個符合模式的資料夾。
Copyright © Windows教程網 All Rights Reserved