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.

screenshot enter image description here

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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -