TechKnow

Author Topic: [BAT] Customizable batch line number based file splitter  (Read 2225 times)

0 Members and 1 Guest are viewing this topic.

Offline HcH

  • TechKnow Owner, Ethical Hacker
  • Administrator
  • Uber Member
  • *****
  • Posts: 9936
  • Karma: +2284/-111
[BAT] Customizable batch line number based file splitter
« on: August 22, 2012, 05:39:44 PM »
@echo off
setlocal enabledelayedexpansion
color 0a
echo.
echo  ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
echo  ÛÛ                             ÛÛ                                           ÛÛ
echo  ÛÛ     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ     ÛÛ               Customizable                ÛÛ
echo  ÛÛ                      ÛÛ     ÛÛ   Batch line number based file splitter   ÛÛ
echo  ÛÛ     ÛÛ  ÛÛ ÛÛÛÛÛ ÛÛ  ÛÛ     ÛÛ                                           ÛÛ
echo  ÛÛ     ÛÛÛÛÛÛ ÛÛ    ÛÛÛÛÛÛ     ÛÛ                                           ÛÛ
echo  ÛÛ     ÛÛ  ÛÛ ÛÛÛÛÛ ÛÛ  ÛÛ     ÛÛ  v0.5, 22-AUG-2o12 4                      ÛÛ
echo  ÛÛ     ÛÛ                      ÛÛ                                           ÛÛ
echo  ÛÛ     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ     ÛÛ                                           ÛÛ
echo  ÛÛ                             ÛÛ                                           ÛÛ
echo  ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
echo.
echo  Cutting files ...

rem Change the extension of cutted files
set EXTT=CSV

rem Declare input file
set INPUTFILE=cata.csv

rem Change the cut ranges here
set part1a=1
set part1b=1000

set part2a=1001
set part2b=2000

set part3a=2001
set part3b=3000

set part4a=3001
set part4b=4000

set part5a=4001
set part5b=5000

set part6a=5001
set part6b=6000

set part7a=6001
set part7b=7000

set part8a=7001
set part8b=8000

set part9a=8001
set part9b=9000

set part10a=9001
set part10b=10000

set part11a=10001
set part11b=11000

set part12a=11001
set part12b=12000


:part1
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part1b% goto part2
    if !counter! GEQ %part1a% echo %%a >>%part1a%-%part1b%.%EXTT%

    set /a counter+=1
)

:part2
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part2b% goto part3
    if !counter! GEQ %part2a% echo %%a >>%part2a%-%part2b%.%EXTT%

    set /a counter+=1
)

:part3
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part3b% goto part4
    if !counter! GEQ %part3a% echo %%a >>%part3a%-%part3b%.%EXTT%

    set /a counter+=1
)

:part4
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part4b% goto part5
    if !counter! GEQ %part4a% echo %%a >>%part4a%-%part4b%.%EXTT%

    set /a counter+=1
)

:part5
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part5b% goto part6
    if !counter! GEQ %part5a% echo %%a >>%part5a%-%part5b%.%EXTT%

    set /a counter+=1
)

:part6
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part6b% goto part7
    if !counter! GEQ %part6a% echo %%a >>%part6a%-%part6b%.%EXTT%

    set /a counter+=1
)

:part7
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part7b% goto part8
    if !counter! GEQ %part7a% echo %%a >>%part7a%-%part7b%.%EXTT%

    set /a counter+=1
)

:part8
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part8b% goto part9
    if !counter! GEQ %part8a% echo %%a >>%part8a%-%part8b%.%EXTT%

    set /a counter+=1
)

:part9
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part9b% goto part10
    if !counter! GEQ %part9a% echo %%a >>%part9a%-%part9b%.%EXTT%

    set /a counter+=1
)

:part10
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part10b% goto part11
    if !counter! GEQ %part10a% echo %%a >>%part10a%-%part10b%.%EXTT%

    set /a counter+=1
)

:part11
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part11b% goto part12
    if !counter! GEQ %part11a% echo %%a >>%part11a%-%part11b%.%EXTT%

    set /a counter+=1
)

:part12
SET /a counter=1

for /f "usebackq delims=" %%a in (%INPUTFILE%) do (
    if !counter! GTR %part12b% goto exit
    if !counter! GEQ %part12a% echo %%a >>%part12a%-%part12b%.%EXTT%

    set /a counter+=1
)

:exit