Xcopy - パラメータの数が無効です

Xcopy - パラメータの数が無効です

いくつかのECFファイルをフォルダから新しいフォルダに移動するbatファイルを作成しようとしています

他のドキュメント(.doc、.ppt)などのXCopy batファイルを正常にセットアップし、動作中のXCopy batファイルからテキストをコピーして、*.docを*.ecfに変更しました。

@ECHO OFF

cd C:\Users\Alex.Newton\Documents\Fixes\ProgramName\Binaries
REM This is will copy over .doc documents
FOR %%f IN (*.ecf) DO XCOPY "C:\Users\Alex.Newton\Documents\Fixes\ProgramName\Binaries" "%%f" "C:\Users\Alex.Newton\Documents\Fixes\ProgramName\"
PAUSE

無効なパラメータ数が 9 回発生し、ECF ファイルの数も 9 回であるため、検出はされているものの、コピーは行われないようです。

答え1

パラメータの数が無効です

あなたが持っている:

cd C:\Users\Alex.Newton\Documents\Fixes\ProgramName\Binaries
FOR %%f IN (*.ecf) DO XCOPY "C:\Users\Alex.Newton\Documents\Fixes\ProgramName\Binaries" "%%f" "C:\Users\Alex.Newton\Documents\Fixes\ProgramName\"

上記のxcopyコマンドには 3 つの引数があります。

"C:\Users\Alex.Newton\Documents\Fixes\ProgramName\Binaries"
"%%f" 
"C:\Users\Alex.Newton\Documents\Fixes\ProgramName\"

の構文は次のxcopyとおりです。

XCOPY source [destination] [options]

3番目の議論はないオプション(xコピー)。


xopy を呼び出す正しい方法

すでに正しいディレクトリにいるため、C:\Users\Alex.Newton\Documents\Fixes\ProgramName\Binaries最初の引数は必要ありません。

FOR %%f IN (*.ecf) DO XCOPY "%%f" "C:\Users\Alex.Newton\Documents\Fixes\ProgramName\"

または:

FOR %%f IN (*.ecf) DO XCOPY "C:\Users\Alex.Newton\Documents\Fixes\ProgramName\Binaries\%%f" "C:\Users\Alex.Newton\Documents\Fixes\ProgramName\"

参考文献

関連情報