Search code examples
batch-filecommand-linedos

Batch scripting: for /f did not work - invalid syntax


I using MS-DOS 7.10. My bash script is to copy all files in current and subfolder to another folder (I dont want to use xcopy). I used

For /f %%Y In (DirPath) Do

MS-DOS says "Invalid Syntax". What wrong with this command? Is it unsupported by command.com?


Solution

  • You need to show us a little more of your batch.

    In all probability, you are following the DO with a block.

    A statement-sequence, counting as a single statement may be (parenthesised over many lines if you like) but if used on an IF statement, the IF and ( must be on the same physical line (similarly, in a FOR..DO, if a block is used, the DO and ( must be on the same physical line).

    If however you are using real, genuine MSDOS rather than CMD (the windows emulator) then for /f is not supported under MSDOS