|
Answer» Win XP Cmd.exe
A line in a file contains Detail
Is there any way to copy this to another file using the Echo command?To echo special characters such as < > etc we "escape" them. The escape character for most special characters is the caret (^)
Code: [Select]C:\>echo Detail ^<trial^>^<test1.2^> Detail <trial><test1.2> Code: [Select]C:\>echo Detail ^<trial^>^<test1.2^> > test.txt
C:\>TYPE test.txt Detail <trial><test1.2> THANK you ST.
The line is already part of a file to which I cannot add the CARETS. I can also Echo the line if it is enclosed in double quotes but then of COURSE cannot remove the " " in the output file.
Is there any code with which I can input the line, add the carets then Echo the line to an output file?Using FOR you can echo each line... This below example works. as shown.. if it is not appropriate for your problem please show an example of part of an input file and state how you are processing it in a batch
Code: [Select]@echo off echo Detail ^<trial^>^<test1.2^> > test1.txt echo Detail ^<trial^>^<test1.3^> >> test1.txt echo Detail ^<trial^>^<test1.4^> >> test1.txt echo Detail ^<trial^>^<test1.5^> >> test1.txt echo Detail ^<trial^>^<test1.6^> >> test1.txt
echo Input file: type test1.txt
if EXIST test2.txt del test2.txt
for /f "delims=" %%A in (test1.txt) do ( echo %%A >> test2.txt )
echo Output file: type test2.txt Code: [Select]Input file: Detail <trial><test1.2> Detail <trial><test1.3> Detail <trial><test1.4> Detail <trial><test1.5> Detail <trial><test1.6> Output file: Detail <trial><test1.2> Detail <trial><test1.3> Detail <trial><test1.4> Detail <trial><test1.5> Detail <trial><test1.6>"A line in a file contains" - If this is true, then you may want to look into the find or findstr command to first find a line of code before copying it out to a new file.Thank you both. Matter resolved by switching on brain.
Cheers.
|