Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
batch to delete end of line
Name: imrsi25 Date: May 17, 2009 at 02:14:16 Pacific OS: Windows XP Pro SP3 Product: Lenovo / C200 Subcategory: Batch
Comment:
How can I delete all text in every single line in txt file after specific sign in line.
For example, if I have: eeeeeeeeee \: marko bbbbbbbbbbbbb \: juuure vvvvvvvvvvvvvvvvvvvv \: sanader
I want to delete all text after "\:", and my new.txt has to looks like:
Name: Mechanix2Go Date: May 17, 2009 at 04:17:23 Pacific
Reply:
@echo off > newfile & setLocal EnableDelayedExpansion
for /f "tokens=1-2 delims= " %%a in (myfile) do ( echo %%a %%b >> newfile )
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: imrsi25 Date: May 17, 2009 at 04:34:23 Pacific
Reply:
The response was very quickly and successful!
Thank you very much.
0
Response Number 3
Name: m00g13 Date: August 3, 2009 at 09:20:32 Pacific
Reply:
Is it possible to achieve this same effect, but delete the contents of the line prior to the "\:" symbol. So for example, after running the batch on the text file mentioned in the first post, we'd have:
marko jure sanader
0
Response Number 4
Name: m00g13 Date: August 3, 2009 at 16:19:33 Pacific
Reply:
Also of note - it seems the batch file above uses just "\" as the delim, as opposed to "\:". Is it possible to use the entire string \: as the delim?
0
Response Number 5
Name: ghostdog Date: August 3, 2009 at 17:02:51 Pacific
Reply:
this is easily done with vbscript too
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\test\file.txt"
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
s = Split(strLine,"\:")
WScript.Echo s(UBound(s))
Loop
objFile.Close
Summary: I’m trying to making a batch file that replaces a word with another in a file(s!) that containing the word. By using Edlin program. And to use edlin so req. it ^Z (Ctrl+Z) as a breaker between old t...
Summary: I'm not understanding: >Actually command is adding the text at the start of all the line. The two solutions I gave you do append the text to the end of the line. In the sed example, $ is a regular ex...