|First of all replace the Split.bat code with the following revised version that is more efficient and has full check of the parameter file:|
:: SPLIT.BAT Usage: split [device:][pathname]filename
@echo off & setlocal EnableDelayedExpansion
if not defined param (
echo. Usage: split [device:][pathname]filename
if not exist "%param%" (
echo. File "%param%" not found
for %%j in ("%param%") do (
for /F %%j in ('type "%param%" ^| find /V /C ""') do set Half=%%j
set /A Half/=2
type nul > "%name%_A%ext%"
type nul > "%name%_B%ext%"
for /F "tokens=1* delims=]" %%j in ('type "%param%" ^| find /V /N ""') do (
set /A N+=1
if !N! gtr %Half% set X=B
Then the easiest way to perform mass splitting is to call the above batch from a main one, i.e.
:: MASSPLIT.BAT Usage: massplit Folder_Name
echo. Splitting, please wait...
for /F "delims=" %%j in ('dir /B *.txt') do call %~dp0\split %%j
Store both scripts into the same directory and then type e.g.
massplit C:\My Dir\test
The process may take mimutes so be patient. I tested the script under Win 2K/XP and it worked fine.
You can directly put it into a For loop, but that requires a bit of code rearranging and so I selected the shortest way.
The scientist Enrico Fermi who built the first nuclear reactor (and then the atomic bomb in Los Alamos) loved to reinvent the wheel and he discovered new ways to build wheels.
Anyway sometime it is better to be able to perform a calculation by your own hands even if you can't operate a calculator or a computer.