Character Limit and Nested FOR loops

Microsoft Windows
Post Reply
User avatar
Posts: 336
Joined: 2021-Jul-12, 1:37 pm

Character Limit and Nested FOR loops

Post by MigrationUser »

01 Jul 2011 03:25

On this page near the bottom under the Long Commands and long filenames, it states that the commands are limited to 8190 characters. Does this included nested FOR loops?

For instance, if I were to break down the commands in the FOR loops to their own lines, is that all included as one command as to where the character count begins at the very beginning of the very first for loop? Or does the character count reset once I enter a command on it's own line in the FOR loop?

Last edited by //[T.0.P]// (01 Jul 2011 03:26)


#2 02 Jul 2011 11:24
Simon Sheppard

Re: Character Limit and Nested FOR loops

I'm pretty sure its the latter, but I havent tested it.

(Actually the max length is 8192 minus a line termination character = 8191) ... limitation


#3 13 Jul 2011 17:32

for %%A in (fubar.txt) do call :DoSomething "%%~A"

will get you around any command length limitation you're ever likely to strike.


#4 15 Jul 2011 17:59

Hi flabdablet,

nice try, but it will also fail with more than 8192 characters in %%A.

Currently there seems no possible way to create a single command line with more than 8192 characters,
independent if you write them directly or from a percent, delayed or FOR-variable expansion.

Of course a block command in parenthesis can consists of more than the limit, but only on multiple lines.

Post Reply