1
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?

More than 1 year has passed since last update.

Windowsのbatでユーザーの入力値を元に処理

Posted at

やり方

入力値を元にファイルやフォルダーを検索するサンプル
rem このbatと同じフォルダーに存在している、ファイルやフォルダーの部分一致検索。
rem 検索文字列はユーザーからの入力値。

rem ユーザーからの入力値を保持する変数。
set input_from_user_=

rem ユーザーに入力してもらう。
set /p input_from_user_="検索する単語を入力して下さい。"

rem 検索。
dir *%input_from_user_%*

rem 検索結果が確認できるように、コマンドプロンプト画面を閉じずに残す。
pause

bat起動すると下記。
image.png

フォルダーの構成が下記の場合…
image.png

『あああ』と入力すると、その値を使って処理が行われる。
image.png

なんでもいいのでキー入力するとコマンドプロンプト画面は閉じる。

参考サイトさん

バージョン

Windows 10 Pro 22H2 19045.3208

1
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
1
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?