HELO FRIENDS !
I NEED a batch file to extract the 2 first lines of a txt file generated by DU.exe renamed for W7 by me, as Dudir.exe
to bypas de DU command W7. It works perfect.
The information which I get as result in a 1. txt file is:
Files: 125
Directories: 4
Size: 230.456.786 bytes
Size on disk: 230.456.786 bytes
I want to get a new 2.txt file BUT ONLY WITH THE 2 FIRST LINES
Files: 125
Directories: 4
I tryed a lot of posibilities with FOR but I'm not an expert in FOR
Please can some one help me with the correct code
Thanks in advance for the help
EXTRACT THE 2 FIRST LINES OF A TXT FILE AND COPY TO ANOTHER TXT FILE
Moderator: DosItHelp
Re: EXTRACT THE 2 FIRST LINES OF A TXT FILE AND COPY TO ANOTHER TXT FILE
You could give this a try.
Code: Select all
dudir.exe -n -q |findstr /b /i "Files: Directories:" >file2.txt
Re: EXTRACT THE 2 FIRST LINES OF A TXT FILE AND COPY TO ANOTHER TXT FILE
this will print the first two lines of SOME_FILE.txt:
Code: Select all
break>"%temp%\empty"&&fc "%temp%\empty" "SOME_FILE.txt" /lb 2 /t |more +4|findstr /B /E /V "*****"
Re: EXTRACT THE 2 FIRST LINES OF A TXT FILE AND COPY TO ANOTHER TXT FILE
Code: Select all
@echo off
setlocal
( set /P "line1=" & set /P "line2=" ) < input.txt
(
echo %line1%
echo %line2%
) > output.txt
Antonio
Re: EXTRACT THE 2 FIRST LINES OF A TXT FILE AND COPY TO ANOTHER TXT FILE
Thank you very much friends
The first solution is perfect
The second close the batch file
The solution 3 give me a message "echo is desactivated"
and in any case what for and why is setlocal necessary ?
Thanks
Jorgegs
The first solution is perfect
The second close the batch file
The solution 3 give me a message "echo is desactivated"
and in any case what for and why is setlocal necessary ?
Thanks
Jorgegs