2016-10-13 6 views
0

cmd.exeコンソールで次の行を実行すると動作します。私は私のバッチスクリプトで同じ行を貼り付けると私はなぜコマンドラインで動作しますがバッチスクリプトでは動作しません

FOR /d /r ./ %d IN (*Images) DO @IF EXIST "%d" RD /s/q "%d" 

それは言う:

d" RD /s/q "d" was unexpected at this time. 
+3

for /?は、最初の画面(9行目)に述べています。これはヘルプファイルの一番上にあるように、15秒間で読むことができました。 'バッチプログラムでFORコマンドを使用するには、%variableの代わりに%%変数を指定します。 ' – Squashman

答えて

1

代わり%variable%%variableを指定し、バッチプログラムでFORコマンドを使用するには。あなたが使用しているコマンドのヘルプファイルを読んでいないので

==> for /? 
Runs a specified command for each file in a set of files. 

FOR %variable IN (set) DO command [command-parameters] 

    %variable Specifies a single letter replaceable parameter. 
    (set)  Specifies a set of one or more files. Wildcards may be used. 
    command Specifies the command to carry out for each file. 
    command-parameters 
      Specifies parameters or switches for the specified command. 

To use the FOR command in a batch program, specify %%variable instead 
of %variable. Variable names are case sensitive, so %i is different 
from %I. 
関連する問題