Warning: include_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 2

Warning: include_once(http://www.confrage.com/bin/header.php): failed to open stream: no suitable wrapper could be found in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 2

Warning: include_once(): Failed opening 'http://www.confrage.com/bin/header.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 2
コマンドプロンプトの置き換え可能パラメータとshift | 株式会社CONFRAGE
Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 17

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/menu.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 17
コマンドプロンプトの置き換え可能パラメータとshift
コマンドプロンプト上でバッチファイルを実行する時、パラメータを指定することが出来ます。パラメータはバッチファイル中で使用できる変数のことです。パラメータを指定するにはコマンドプロンプト上で以下のように書きます。

a.bat hello bye

これはa.batというバッチファイルを実行する時にパラメータとしてhelloとbyeを指定しています。
パラメータをバッチファイル中で使用するには 置き換え可能パラメータ%0~%9 を使用します。上の例では、%1にhello、%2にbyeが入ります。%0にはバッチファイル名a.batが入ります。
必要であればパラメータはバッチファイル名を除いて(%0を除いて)9個まで(%1から%9まで)指定できます。もし%9を越えるパラメータが必要な時はshiftコマンドを使用して可能にします。

shiftコマンドは、各パラメータを直前のパラメータにコピー(%1は%0にコピー、%2は%1にコピーする)して10個目のパラメータがあれば%9にコピーするコマンドです。もし11個目のパラメータがあればそれは10個目のパラメータとなります。実行前に%0に格納されていた値は消えて二度と戻すことはできません。
以下はshiftコマンド実行前と実行後のパラメータの状態を表にして書いたものです。

≪shiftコマンド実行前と実行後のパラメータの状態≫
%0%1%2%3%4%5%6%7%8%910個目の引数
a.batbcdddefghi
shiftを実行するとパラメータは以下の状態になる↓
bcdddefghi 
shiftコマンドのオプション
/n (nには0~8が入る) を指定すると、n番目の引数からshiftコマンドが実行されます。たとえば、

shift /2

を実行すると、%3は%2へコピー、%4は%3へコピーというようになります。実行前に%2に格納されていた値は消えて、%0と%1は実行前と実行後で変わりはありません。

≪shiftコマンドの使い方≫
@echo off

rem このバッチファイルは、任意の数のファイルを
rem %1で指定したディレクトリにコピーします。
rem 次のコマンド構文を使います。
rem mycopy mydir file1 file2 ...

set mydir=%1
:getfile
shift
if "%1"=="" goto end
copy %1 %mydir%
goto getfile
:end
set mydir=

Back to top

Information

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 103

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/side_bar.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 103

Warning: include_once(/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php): failed to open stream: No such file or directory in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 112

Warning: include_once(): Failed opening '/home/sites/heteml/users/m/o/r/moriya-h5/web/confrage/bin/seo.php' for inclusion (include_path='.:/usr/local/php/5.6/lib/php') in /home/users/2/moriya-h5/web/confrage/dos/batch-grammar/param/param.html on line 112