Forums: Batch File Question - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Batch File Question

#1 User is offline   r00t 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 85
  • Joined: 17-June 03

Posted 18 April 2005 - 11:49 PM

HI people,

I have a problem i wanna let check a batch file a txt file and let ehm copy out a string to a destination txt file.

Like all between ; ; schould be copyed in an other txt and for every string a new line @ destination txt.

Anybody any ideas ?

THX

Example :


source.txt :

bla bla bla ;string; bla bla bllsdsjdj ;string2; bla bla
bla blaaa bla bla bli
bla bla
bla text bla ;string3; bla bla ;string4;.


I wanna Copy string ,string2, string3, string4, into a second text file. And each string on one line of the Destination file.

destination.txt :

string
string2
string3
string4
0

#2 User is offline   aelphaeis_mangarae 

  • Members
  • Icon
  • Group: Members
  • Posts: 936
  • Joined: 22-January 04

Posted 19 April 2005 - 02:23 AM

Maybe you could explain to us better what you want, i don't understand what you said just gives me a headache...
:: Black Hat Forums ::
http://blackhat-forums.com
0

#3 User is offline   da_cash 

  • Sergeant
  • Icon
  • Group: Members
  • Posts: 232
  • Joined: 27-January 04

Posted 19 April 2005 - 03:51 AM

I don't know what do you exactly want but if your file looks like

something;something;something

and you just want to sort everything then create a bat file with
@echo off 
FOR /F "tokens=1,2,3* delims=;" %%i in (input.txt) do echo %%i >>out1.txt | echo %%j >>out2.txt | echo %%k >>out3.txt


and this will create 3 separate files for data inside ;; ..
0

#4 User is offline   aelphaeis_mangarae 

  • Members
  • Icon
  • Group: Members
  • Posts: 936
  • Joined: 22-January 04

Posted 19 April 2005 - 04:32 AM

Sorry can't help you...
:: Black Hat Forums ::
http://blackhat-forums.com
0

#5 User is offline   ktr 

  • Private
  • Icon
  • Group: Members
  • Posts: 18
  • Joined: 22-May 03

Posted 23 April 2005 - 01:16 AM

it seems you only need to fetch rows where ; is present and 2nd and 4th field.

@echo off
FOR /F "tokens=2,4 delims=;" %%a in ('TYPE source.txt^| FIND ";"') do (echo %%a >>destination.txt&& echo %%b >>destination.txt)


I tested with your source.txt example and works fine

Enjoy ;)
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

  • Share



Our Sponsors:


SwiftLayer Affiliate Web Hosting