Here https://stackoverflow.com/questions/121 ... atch-files and here https://groups.google.com/g/alt.msdos.b ... _H4JWPih-A (for MS-DOS 6.22) that there is not file size limit to .bat/.cmd. But...
Over the weekend I generated (with another .cmd of course) a .cmd 80+ MB in size so I was wondering if there is a size limit to the batch file. I thought of two possible size limits: 2GB and 4GB. It turns out that there is a 2 GB size limit. Batch will not crash - it will start from the beginning. Here www.kockarna.si/test.zip is a test.cmd (.zip is 106 MB, test.cmd when extracted is 4+ GB, 40,000,005 lines). Test.cmd contains
Code: Select all
@echo off
:: XXXXXXXXXXXXXX (actually there are more Xs - total line length is 110 bytes (including CR+LF)
:: XXXXXXXXXXXXXX
:: XXXXXXXXXXXXXX
:: XXXXXXXXXXXXXX
echo line 10 000 000
:: XXXXXXXXXXXXXX
:: XXXXXXXXXXXXXX
.
.
.
echo line 20 000 000
Code: Select all
c:\echo %time%&test.cmd
16:54:55,92
line 10000001
line 10000001
C:\findstr /N /I /C:"line" test.cmd
test.cmd:10000002:Echo line 10000001
test.cmd:20000003:Echo line 20000002
test.cmd:30000004:Echo line 30000003
test.cmd:40000005:Echo line 40000004
In a .zip there are also two files: test.exe - it will generate test.cmd (on my machine test.exe finishes very quickly (in a few seconds) but then I have to wait for the cache to be written to the disk - so please be patient if test.cmd's size is still 0 bytes) and test.pb - PureBasic source (see PureBasic.com for demo version if needed).
I doubt that there is a line limit - I think the pointer where current .bat is at (when executing) is in the offset so it has nothing to do with the lines (.bat does not use line numbers (remember BASIC?) and because Aacini wrote a SETFILEPOINTER - same thing I would say). And it would not crash because 40 million is very low number if compared to 2GB.
Also: FIND and NOTEPAD report that the file is too big to process. FINDSTR was able to process it.
This test was done on Windows 10, x64.
Test on XP Pro, x86 will follow.
Saso