Computing.Net > Forums > Programming > batch to delete end of line

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

Reply to Message Icon

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:

eeeeeeeeee \:
bbbbbbbbbbbbb \:
vvvvvvvvvvvvvvvvvvvv \:

Can someon help me?



Sponsored Link
Ads by Google

Response Number 1
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

GNU win32 packages | Gawk


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: August 3, 2009 at 22:48:51 Pacific
Reply:

@echo off > newfile & setLocal EnableDelayedExpansion

for /f "tokens=3 delims= " %%a in (myfile) do (
echo %%a >> newfile
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 7
Name: imrsi25
Date: August 4, 2009 at 01:48:17 Pacific
Reply:

Thank you so much everyone for your answers.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch to delete end of line

How to remove end-of-line in a file www.computing.net/answers/programming/how-to-remove-endofline-in-a-file/10873.html

Sed:Add text to end of line in file www.computing.net/answers/programming/sedadd-text-to-end-of-line-in-file/15109.html

batch to delete text file header www.computing.net/answers/programming/batch-to-delete-text-file-header/15107.html