|
Answer» Hi
I had ever start a topic but it desappeared...
I want to copy the first line of a txt file to the last line of an other txt file. I think to the >> command but i don't know how to select only the first line of the first txt.
Thanks for the help
@+MaxA FOR statement will create a loop to read all the RECORDS in the file. If there is only one record in the file, you're good to go, otherwise there needs to be something unique in the first record for you to key off of. Of course you could use a Windows script
We need more info on the file layout. Hi
Thanks for the answer
I do DIR /b /o:-N rep1 > toto1.txt with a undeterminated number of files in rep1 dir /b /o:-N rep2 > toto2.txt with a undeterminated number of files in rep2 ... and i want to put the first line of each file toto in tata.txt but for toto1 in line 1, toto2 in line 2 and so..
one more thing, all the files in each folder have the same NAME mask (in rep1 *-A.jpg, in rep2 *-B.jpg...)
And to be complete, the BATCH needs to work under XP and 2K
Thanks for the help.
@+MaxI'm not really sure I understand, but my last living brain cell interprets this as you want the first line of two different directory listings (toto1 & toto2) to appear in a third file (tata.txt).
This might work for you. It's untested and I don't debug on Saturdays.
Code: [Select] dir /b /o:-N rep1 > toto1.txt dir /b /o:-N rep2 > toto2.txt for /f "tokens=1*" %%a in (toto1.txt) do ( set line1=%%a goto next ) :next for /f "tokens=1*" %%a in (toto2.txt) do ( set line2=%%a goto next ) :next echo line1 > tata.txt echo line2 >> tata.txt Good luck.
Are we back in Kansas yet?Hi
I try your SOLUTION and i found a little mistake (i think)
that not work ":next echo line1 > tata.txt echo line2 >> tata.txt " it put line1 in line1 of the txt instead of the file name..
this work ":next echo %line1% > tata.txt echo %line2% >> tata.txt "
but the for loop is perfect, thanks your last brain cell work better than my entire brain.. )
@+Max
|