Need a script which can create a file using the data of another file.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Need a script which can create a file using the data of another file.

  1. #1
    Join Date
    Jan 2005
    Location
    Houston, TX
    Posts
    2

    Talking Need a script which can create a file using the data of another file.

    I've done a ton of scripting in Perl, but right now I just need something small done in VBS, and I dont have the time to do it myself and learn VBS.

    What I need done is the following, running on a windows 2003 server.

    I have a file named d.txt containing a list with names for example :
    names:
    eric
    bob
    bethany

    I want this script to read each line and create a file e.txt making the output like this :

    my name is eric banner
    my name is bob banner
    my name is bethany banner

    The first : names line is to be ignored.

    This is something very simple, I looked at some snippets, but VBS is something complely different for me.

    Any takers?

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    OK, but just this once. ;-)
    Code:
    Set fs = CreateObject("Scripting.FileSystemObject") 
    Set inFile = fs.OpenTextFile("d.txt")
    Set outFile = fs.OpenTextFile("e.txt", 2, True)  ' 2 = ForWriting
    
    inFile.ReadLine
    Do Until inFile.AtEndOfStream
        sText = inFile.ReadLine
        If Len(sText) Then
            outFile.WriteLine "my name is " & sText & " banner"
        End If
    Loop
    
    outFile.Close
    inFile.Close
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jan 2005
    Location
    Houston, TX
    Posts
    2
    Thank you so much!

    Works like a charm, I downloaded qbasic from a museum and did it in basic. But this is way way nicer Qbasic is in my recycle bin where it belongs.

    Thanks again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center