|
Answer» Batch script problem:splitting a BIG txt file into many 4000 lines script:
Code: [Select]echo off SETLOCAL enableextensions disabledelayedexpansion
set "nLines=4000" set "line=0" for /f %%a in ('type file.txt^|find /c /V ""') do set "fileLines=%%a"
< "file.txt" (for /l %%a in (1 1 %fileLines%) do ( set /p "data=" set /a "file=1+line/%nLines%", "line+=1" setlocal enabledelayedexpansion >>"pass!file!.txt" echo(!data! endlocal ))
endlocal Line 4001 is not empty,LOOKS strange,here snapshot:
On my Laptop this script works perfect on my pc and my rdp NO,i don't understand why What is generating the Text File? And curious why not just FTP the file from remote system to yourself vs splitting it into 4000 line chunks?You do not need the lines variable. You COULD just write that line like this.
Code: [Select]set /a "file=1+(%%a-1)/nLines"Not sure what your NULL issue is. As far as I know, batch cannot generate a null character on its own.
Quote Not sure what your NULL issue is. As far as I know, batch cannot generate a null character on its own.
Were both on same page with that one. That's why I also asked what is generating this text file.
|