title: Split a file using windows batch script
body: <p>I have a csv file and i need to split it in to n files such that each split file should not exceed 100 mb. I need to achieve it in windows batch script. I tried the below way but its taking lot of time as my unsplit file is in GBs</p>
  
  <pre class="lang-vb prettyprint-override"><code>@echo off
  setlocal enableextensions enabledelayedexpansion
  set count=1
  set maxbytesize=100000000
  set size=1
  type NUL &gt; output_1.csv
  
  FOR /F  "tokens=*" %%i in (myfile.csv) do (
  FOR /F "usebackq" %%A in ('!filename!_!count!.csv') do (
  set size=%%~zA) 
  if !size! LSS !maxbytesize! (
  echo %%i&gt;&gt;!filename!_!count!.csv) else (
  set /a count+=1 
  echo %%i&gt;&gt;!filename!_!count!.csv 
  ))
  </code></pre>
  
  <p>please let me know if there is a better way to achieve this. I cant go to any other scripting languages as my server is windows</p>