Windows多種命令列工具搜尋檔案

Windows 上還有多種命令列工具可用來搜尋檔案。以下是常見工具的比較表,涵蓋功能、語法與適用情境。

🧰 Windows 常見檔案搜尋命令列工具比較

工具名稱 功能簡述 支援遞迴 支援萬用字元 顯示詳細資訊 適用情境與特色
where 根據 PATH 或指定目錄搜尋檔案 /r /t /f 對應 PATH 環境變數,快速找可執行檔
dir 列出目錄內容,可搭配萬用字元搜尋 /s /q /t 最基本的搜尋方式,適合快速列出檔案
for + dir 搭配迴圈進行條件式搜尋 可結合邏輯判斷與批次處理
findstr 在檔案內容中搜尋文字 /s 搜尋檔案內文(如程式碼、設定檔)
fc 比較兩個檔案的內容差異 用於檔案比對(ASCII、Unicode、Binary)
comp fc 類似的檔案比對工具 支援 Binary 比對,較少使用
CMDSearch 第三方批次工具,整合 dirfindfc /S 開源工具,支援多條件搜尋與比對

🧪 範例比較

1. 使用 dir 遞迴搜尋 .txt 檔案

cmd

dir /s /b *.txt

→ 顯示目前目錄與子目錄中所有 .txt 檔案的完整路徑。

2. 使用 findstr 搜尋含關鍵字的檔案

cmd

findstr /s /i "error" *.log

→ 在所有 .log 檔案中搜尋包含 "error" 的行。

3. 使用 fc 比對兩個檔案內容

cmd

fc /n /w config.old config.new

→ 顯示兩個設定檔的差異,忽略空白與顯示行號。

4. 使用 CMDSearch 搜尋特定屬性檔案(需安裝)

cmd

SEARCH FILE /NAME .bat /A:R /S

→ 搜尋所有唯讀 .bat 檔案。

🧩 建議使用情境

  • 快速找執行檔where
  • 列出檔案清單dir
  • 搜尋檔案內容findstr
  • 比對檔案差異fccomp
  • 進階條件搜尋CMDSearch(適合教學或自動化)

Also See

File5FileLast Modified
Windows 如何用where找檔案Windows 如何用where找檔案1:26 AM - December 07, 2025
Windows PowerShell Execution PolicyWindows PowerShell Execution Policy1:26 AM - December 07, 2025
windows batch file with path namewindows batch file with path name1:26 AM - December 07, 2025
UntitledUntitled1:25 AM - December 07, 2025
Everything極高速Windows 檔案搜尋工具Everything極高速Windows 檔案搜尋工具1:25 AM - December 07, 2025