Skip to content

Instantly share code, notes, and snippets.

@bigga
Created March 29, 2022 14:10
Show Gist options
  • Save bigga/4491a1367654a21da7eb6e3a1921d64f to your computer and use it in GitHub Desktop.
Save bigga/4491a1367654a21da7eb6e3a1921d64f to your computer and use it in GitHub Desktop.
Split Files Batch
@echo off
setlocal ENABLEDELAYEDEXPANSION
REM Edit this value to change the name of the file that needs splitting. Include the extension.
REM Edit this value to change the number of lines per file.
SET LPF=5000
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=%~n1
SET SFX=%~x1
REM Do not change beyond this line.
SET /A LineNum=0
SET /A FileNum=1
For /F "delims==" %%G in (%1) Do (
SET /A LineNum+=1
echo %SFN%!FileNum!%SFX%
echo %%l >> %SFN%!FileNum!%SFX%
if !LineNum! EQU !LPF! (
SET /A LineNum=0
SET /A FileNum+=1
)
)
endlocal
Pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment