Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

Windows 7 內建 CMD 指令複製/刪除資料夾:xcopy、del、rd 完整語法教學

編輯:關於 Windows

遇到頑固無法刪除的資料夾,或需大量複製目錄結構?Windows 7 內建命令提示字元指令比圖形介面更強大、徹底。

複製資料夾(含子目錄)

xcopy f:\file c:\file /e

/e 參數包含空目錄。若僅複製檔案可用 /s。

刪除資料夾(兩步驟)

del /s /q d:\123\*.*   :: 先刪除資料夾內所有檔案(/s 遞迴、/q 安靜模式不確認)
rd /s /q d:\123        :: 再刪除資料夾本身(/s 連同子目錄、/q 不確認)

指令補充說明

  • del 僅能刪除檔案,無法直接刪除目錄。
  • rd(或 rmdir)專門刪除目錄,預設僅限空目錄,需加 /s 才能刪除含子目錄的資料夾。
  • /q(quiet)極為實用:批次刪除時不再逐一詢問 Y/N,請確認路徑無誤後再執行,資料無法復原。

進階技巧

若 rd /s /q 仍因檔案被鎖定失敗,可嘗試:
1. 安全模式執行。
2. 使用 takeown /f 路徑 /r /d y 取得擁有權,再 icacls 路徑 /grant administrators:F /t 賦予權限,最後再刪除。

Copyright © Windows教程網 All Rights Reserved