Search code examples
batch-fileline-continuation

Split long commands in multiple lines through Windows batch file


How can I split long commands over multiple lines in a batch file?


Solution

  • You can break up long lines with the caret ^ as long as you remember that the caret and the newline following it are completely removed. So, if there should be a space where you're breaking the line, include a space. (More on that below.)

    Example:

    copy file1.txt file2.txt
    

    would be written as:

    copy file1.txt^
     file2.txt