0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

エクスプローラーで指定用語のファイルを検索するバッチファイル

Last updated at Posted at 2025-06-07

エクスプローラーでファイル名等を検索して特定のファイル検索しようとしても、膨大なファイル数が保存されているフォルダが対象だと、結局、検索ができないことがあります。

その場合は、エクスプローラーの検索ボックスで検索するのではなく、コマンドプロンプトで検索するとよいでしょう。
下記は、自身のダウンロードフォルダを検索するバッチファイルです。
実行後に検索したいキーワード(例:.pdf)を入力すれば、該当のファイルの一覧を出力してくれます。
対象とするフォルダは、必要に応じて変更してください。

Windowsバッチファイル
@echo off
setlocal

rem サンプル:サブディレクトリ内のログファイルを検索する
rem WHERE /R C:\Work *.* /T > 検索ファイルリスト.txt
rem ファイルサイズ、タイムスタンプ、ファイルのフルパス

:: 検索対象のフォルダを設定(例:ダウンロードフォルダ)
set "targetPath=%USERPROFILE%\Downloads"

:: 検索キーワードを入力
set /p "keyword=検索キーワードを入力してください(部分一致): "

WHERE /R "%targetPath%" *"%keyword%"* /T > 検索ファイルリスト.txt

:: 完了メッセージ
echo 完了しました。結果はバッチファイル保存場所に出力されています。
pause
endlocal

バッチファイルの基本的な説明は、下記の記事等をご参照ください。
【Qiita記事】:ノンプロ向けの便利なバッチファイルの使い道(業務効率化)
久しぶりの記事でした!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?