バッチでテキストファイルをCSV形式で出力
転職して少し日常を取り戻しつつある今日この頃。
久しぶりのブログ更新。
バッチファイルを作成したのでアップします。
■やってること
カレントディレクトリからlogファイルを取得して
フィールドを区切ってソートしてcsvで出力。
@echo off set beforestr= set afterstr=, SETLOCAL EnableDelayedExpansion for /f "delims=" %%i in ('dir /B *.log') do ( set infilenm=%%i set outfilenm=!infilenm:log=csv! echo infilenm=!infilenm! echo outfilenm=!outfilenm! type nul >!outfilenm! for /f "delims=" %%A in (!infilenm!) do ( set line=%%A set line=!line:~5! echo !line:%beforestr%=%afterstr%!>>!outfilenm! ) sort /o !outfilenm! !outfilenm! ) endlocal