Windows多種命令列工具搜尋檔案
Windows 上還有多種命令列工具可用來搜尋檔案。以下是常見工具的比較表,涵蓋功能、語法與適用情境。
| 工具名稱 | 功能簡述 | 支援遞迴 | 支援萬用字元 | 顯示詳細資訊 | 適用情境與特色 |
|---|---|---|---|---|---|
where |
根據 PATH 或指定目錄搜尋檔案 | ✅ /r |
✅ | ✅ /t /f |
對應 PATH 環境變數,快速找可執行檔 |
dir |
列出目錄內容,可搭配萬用字元搜尋 | ✅ /s |
✅ | ✅ /q /t |
最基本的搜尋方式,適合快速列出檔案 |
for + dir |
搭配迴圈進行條件式搜尋 | ✅ | ✅ | ✅ | 可結合邏輯判斷與批次處理 |
findstr |
在檔案內容中搜尋文字 | ✅ /s |
✅ | ✅ | 搜尋檔案內文(如程式碼、設定檔) |
fc |
比較兩個檔案的內容差異 | ❌ | ❌ | ✅ | 用於檔案比對(ASCII、Unicode、Binary) |
comp |
與 fc 類似的檔案比對工具 |
❌ | ❌ | ✅ | 支援 Binary 比對,較少使用 |
CMDSearch |
第三方批次工具,整合 dir、find、fc 等 |
✅ /S |
✅ | ✅ | 開源工具,支援多條件搜尋與比對 |
dir 遞迴搜尋 .txt 檔案cmd
dir /s /b *.txt
→ 顯示目前目錄與子目錄中所有 .txt 檔案的完整路徑。
findstr 搜尋含關鍵字的檔案cmd
findstr /s /i "error" *.log
→ 在所有 .log 檔案中搜尋包含 "error" 的行。
fc 比對兩個檔案內容cmd
fc /n /w config.old config.new
→ 顯示兩個設定檔的差異,忽略空白與顯示行號。
CMDSearch 搜尋特定屬性檔案(需安裝)cmd
SEARCH FILE /NAME .bat /A:R /S
→ 搜尋所有唯讀 .bat 檔案。
wheredirfindstrfc 或 compCMDSearch(適合教學或自動化)| File5 | File | Last Modified |
|---|---|---|
| Windows 如何用where找檔案 | Windows 如何用where找檔案 | 1:26 AM - December 07, 2025 |
| Windows PowerShell Execution Policy | Windows PowerShell Execution Policy | 1:26 AM - December 07, 2025 |
| windows batch file with path name | windows batch file with path name | 1:26 AM - December 07, 2025 |
| Untitled | Untitled | 1:25 AM - December 07, 2025 |
| Everything極高速Windows 檔案搜尋工具 | Everything極高速Windows 檔案搜尋工具 | 1:25 AM - December 07, 2025 |