FileSplitter Tool – Splitting data file

update the following lines:

set “inputFile=C:\path\to\your\input.txt”
set “outputFolder=C:\path\to\output”
set “linesPerFile=1000”

and here is the bat file:

@echo off
setlocal

:: Set variables
set “inputFile=C:\path\to\your\input.txt”
set “outputFolder=C:\path\to\output”
set “linesPerFile=1000”

:: Create output directory if it doesn’t exist
if not exist “%outputFolder%” (
mkdir “%outputFolder%”
)

:: Run PowerShell to split the file
powershell -Command ^
“$inputFile = ‘%inputFile%’;” ^
“$outputFolder = ‘%outputFolder%\’;” ^
“$linesPerFile = %linesPerFile%;” ^
“$i = 0;” ^
“Get-Content $inputFile -ReadCount $linesPerFile | ForEach-Object {” ^
“$i++;” ^
“$outFile = ‘{0}part_{1}.txt’ -f $outputFolder, $i;” ^
“$_ | Set-Content $outFile” ^
“}”

echo Done!
pause

Leave a Reply

Your email address will not be published. Required fields are marked *