cmd - While splitting txt file through batch script Exclamations are ommitting -
iam new batch script , here tried split text file chunks each 1 million rows. chunk files generated expected, inside output file content iam missing exclamations ( ! ) , skipping immediate column after exclamation. please me data in original file chunks!
@echo off setlocal disabledelayedexpansion set limit=1000000 set feed_name=test.txt set file=%tgt_dir%\%feed_name% set linecounter=1 set filenamecounter=1 set name= set extension= %%a in (%file%) ( set "name=%%~na" set "extension=%%~xa" ) setlocal enabledelayedexpansion /f "tokens=*" %%a in (%file%) ( set splitfile=!name!%date:~12,2%%date:~4,2%%date:~7,2%!filenamecounter!!extension! if !linecounter! gtr !limit! ( set /a filenamecounter=!filenamecounter! + 1 set linecounter=1 echo created !splitfile!. ) echo %%a>> %tgt_dir%\!splitfile! set /a linecounter=!linecounter! + 1 ) endlocal
it tab delimiter file.
you need toggle delayed expansion.
setlocal disabledelayedexpansion /f "tokens=*" %%a in (%file%) ( set "line=%%a" setlocal enabledelayedexpansion set splitfile=!name!%date:~12,2%%date:~4,2%%date:~7,2%!filenamecounter!!extension! echo(!line!>> %tgt_dir%\!splitfile! if !linecounter! gtr !limit! ( endlocal set /a filenamecounter+=1 set linecounter=1 echo created file ) else endlocal set /a linecounter=linecounter + 1 )
Comments
Post a Comment