Computer Hope
Microsoft => Microsoft DOS => Topic started by: karlosss on November 15, 2017, 07:01:07 AM
-
Batch script problem:splitting a big txt file into many 4000 lines
script:
@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:
(http://i63.tinypic.com/2a5gkl.jpg)
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.
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.
-
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. ;D