title: Batch split a text file
body: <p>I have this batch file to split a txt file:</p>
  
  <pre><code>@echo off
  for /f "tokens=1*delims=:" %%a in ('findstr /n "^" "PASSWORD.txt"') do for /f "delims=~" %%c in ("%%~b") do &gt;"text%%a.txt" echo(%%c
  pause
  </code></pre>
  
  <p>It works but it splits it line by line. How do i make it split it every 5000 lines. Thanks in advance.</p>
  
  <p>Edit:</p>
  
  <pre><code>I have just tried this:
  
  @echo off
  setlocal ENABLEDELAYEDEXPANSION
  REM Edit this value to change the name of the file that needs splitting. Include the extension.
  SET BFN=passwordAll.txt
  REM Edit this value to change the number of lines per file.
  SET LPF=50000
  REM Edit this value to change the name of each short file. It will be followed by a number indicating where it is in the list.
  SET SFN=SplitFile
  
  REM Do not change beyond this line.
  
  SET SFX=%BFN:~-3%
  
  SET /A LineNum=0
  SET /A FileNum=1
  
  For /F "delims==" %%l in (%BFN%) Do (
  SET /A LineNum+=1
  
  echo %%l &gt;&gt; %SFN%!FileNum!.%SFX%
  
  if !LineNum! EQU !LPF! (
  SET /A LineNum=0
  SET /A FileNum+=1
  )
  
  )
  endlocal
  Pause
  exit
  </code></pre>
  
  <p>But i get an error saying: <code>Not enough storage is available to process this command</code></p>