Hello,
I want to move the contents of text file and create a new file, condition to move the lines from text file, skip line 1 and last line.
Text file:
first line to skip...
33100xxxxx........
33220xxxxx.....
33340xxxxx......
33100xxxxx.....
last line to skip..
From 2nd line skip first 2 digits & next 3 digits will decide which lines will remain in the file. If its 100 it will remain there others will be moved to new file.
Result:
first line ..
33100xxxxx........
33100xxxxx.....
last line...
New file:
33220xxxxx.....
33340xxxxx......
Any Helps.
Move the Contents of Text file
Moderator: DosItHelp
Re: Move the Contents of Text file
What do the first and last lines look like? Obfuscating data examples usually creates multiple rewrites of a script because we don't know all of the information.
Re: Move the Contents of Text file
Hello,
Sample data.
Sample data.
23102014
2230002100310000101028330 000000071800002643333455446821348
2210002100210000022711 000000164200002643138993934699262
222130210021000010104 000000020600002643580679455001503
22315021002103010000029 000000021200002643339123491688650
223100210021030100000295 000000021200002642875269641084560
223150210021044006 000000005290002643788041572501935
22600021003111314 000001022977802642520322031377114
23102014 Total : 0020104008441
Re: Move the Contents of Text file
Perhaps is this what you want?
EDIT: I changed my original answer...
remain.txt:
new.txt:
Antonio
EDIT: I changed my original answer...
Code: Select all
@echo off
setlocal EnableDelayedExpansion
del remain.txt new.txt 2>NUL
set i=0
for /F "delims=" %%a in (file.txt) do (
set /A i+=1
if !i! equ 1 (
echo %%a>> remain.txt
) else if !i! gtr 2 (
if "!line:~2,3!" equ "100" (
echo !line!>> remain.txt
) else (
echo !line!>> new.txt
)
)
set "line=%%a"
)
echo !line!>> remain.txt
remain.txt:
Code: Select all
23102014
2210002100210000022711 000000164200002643138993934699262
23102014 Total : 0020104008441
new.txt:
Code: Select all
2230002100310000101028330 000000071800002643333455446821348
222130210021000010104 000000020600002643580679455001503
22315021002103010000029 000000021200002643339123491688650
223100210021030100000295 000000021200002642875269641084560
223150210021044006 000000005290002643788041572501935
22600021003111314 000001022977802642520322031377114
Antonio
Last edited by Aacini on 05 Nov 2014 16:39, edited 1 time in total.
Re: Move the Contents of Text file
Hi,
SUPERB, EXCELLENT Aacini
Thanks.
SUPERB, EXCELLENT Aacini
Thanks.