Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi....
I need some help with a batch to extract only part of a text string in a file..eg:
Myfile.txt has lines consisting of "this is a text line"
I need to know how to remove "this" and output "is a text line" to another file?
the first word is the only part not needed i should mention each of the first word in each line ends with ">" without a space eg: "string>"
Any help would be appreciated :) thanks in advance.

Maybe this helps:
FOR /f "skip=2 delims= " %%a in ('find "is a text line" Myfile.txt') do >%%askip=2 means not to seek in the first two lines
(not necessary)
delims=" is what you need. After= you give the
last sign before
the words you are seeking and the last sign. like
"delims=x " or whatever.
beginning and empty at the end of the word your
seeking for).uli

Hi Uli..
This works but results in giving me the first word in the string...the part i dont need eg: "this> is a string" resulting in an output of "this>" ( using > as the delims)
Also i do not know what the strings consist of, the only constant is ">"
Am i making a mistake somewhere? i tried this....
FOR /f "skip=2 delims=>" %%a in ('find/v "0.0.0.0" Myfile.txt') do echo>%%aI can still use this elsewhere though or something along those lines
thanks for your help
dual

Hi dual,
if I understand right I know the mistake.
"delims=>"
takes > as last sign."delims=>-"
takes > as first sign and - as last sign. (for example)So you need a start and a end sign.
This should work.uli

Hi again Uli...
Thanks for you help and time :)
I managed to solve it with a slight difference..here is my solution:
FOR /F "tokens=2,3* skip=2 delims= " %%i in ('find ">" Myfile.txt') do echo %%i %%j %%k>>line.txtMyfile.txt contains :
this> is a line
this> is another line
this> is yet another lineline.txt contains :
is a line
is another line
is yet another line
Your first post gave me the insight :)thanks again !
dual

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |