LoginSignup
10

More than 5 years have passed since last update.

posted at

updated at

備忘録バッチファイル

etc

コメントの書き方

現在いるディレクトリの絶対パスを取得

%cd% と書く。
使用例↓

csvmake4 c:\mydoc\test.xls %cd%\xlstemp

for

forループ内でカウンタを用いる

通常の環境変数ではカウントアップ/カウントダウンができない。
そこで遅延環境変数を用いる。

setlocal ENABLEDELAYEDEXPANSION

set /a num=0

for %%i in (*.txt) do (
    set /a num=num+1
    echo count:!num!
)

setlocal ENABLEDELAYEDEXPANSION で宣言しておく必要がある。
遅延環境変数は %num% ではなく !num! と囲む。

http://d.hatena.ne.jp/inspfightman/20080705/1215253544
http://ameblo.jp/phyco/entry-11595146120.html

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
What you can do with signing up
10