0
1

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 3 years have passed since last update.

batファイルでディレクトリのファイル一覧を取り出して他のexeに処理させる

Last updated at Posted at 2020-08-13

batファイルで

  • ディレクトリのファイル一覧を取り出す
  • 他のexe(またはbat)に処理させる
  • 処理結果ファイルなどは指定フォルダに出力する

なんて処理はよくありますが、都度調べるのでメモ

@echo off
rem フォルダのファイル一覧を取得し、exeを実行してresultに結果を出力する例

SET DIR=C:\tmp\*.txt
SET EXE=shori.exe
SET RESULT=.\result

for %%A in (%DIR%) do (
	CALL %EXE% %%A %RESULT%
)
pause

※shori.exeは処理を行って、対象のフォルダに結果の出力(ファイルなど)を返す機能を持っているとします。

出力が無い場合はSET RESULT=, %RESULT%を除けばいいかと。

@echo off
rem フォルダのファイル一覧を取得し、exeを実行

SET DIR=C:\tmp\*.txt
SET EXE=shori.exe

for %%A in (%DIR%) do (
	CALL %EXE% %%A
)
pause
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?