Solved

Script to create import file

Posted on 2013-05-24
2
292 Views
Last Modified: 2013-05-24
I need a script that will read a text file, and for every line in the text file create a few lines of data in a second text file.

input text file looks like this
navs.org.ukhome
negotiationisdone.com
negotiationisdone.wordpress.com
negotiationisover.blogspot.com
negotiationisover.com

I need the out put file to look like this

               edit "navs.org.ukhome"
                    set action block
                    set type wildcard
                next
                edit "negotiationisdone.com"
                    set action block
                    set type wildcard
                next
            edit "negotiationisdone.wordpress.com"
                    set action block
                    set type wildcard
                next
            edit "negotiationisover.blogspot.com"
                    set action block
                    set type wildcard
                next
            edit "negotiationisover.com"
                    set action block
                    set type wildcard
                next
0
Comment
Question by:TheonW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
ZabagaR earned 500 total points
ID: 39195470
This works, I just tried it:

The variable strFileName will be your final OUTPUT file
The file I called c:\servers.txt would contain the list of your .com web sites.
------------------------------------------------------------------------------------------------------------------------------


Const FOR_APPENDING = 8
strFileName = "C:\testfile.txt"
Const ForReading = 1

Set objFS = CreateObject("Scripting.FileSystemObject")
Set MyFile = objFS.CreateTextFile(strFileName, True)
MyFile.Close
Set objTS = objFS.OpenTextFile(strFileName,FOR_APPENDING)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\servers.txt", ForReading)

Do Until objTextFile.AtEndOfStream
    strNextLine = objTextFile.Readline
    arrServiceList = Split(strNextLine , ",")

objTS.Write "edit " & Chr(34) & arrServiceList(0) & Chr(34) & vbCrLf
objTS.Write "set action block" & vbCrLf
objTS.Write "set type wildcard" & vbCrLf
objTS.Write "next" & vbCrLf

Loop
ObjTS.Close
0
 
LVL 3

Author Closing Comment

by:TheonW
ID: 39195635
I made a few changes for spacing and notice that you put the create file first, no big deal,  easy fix, thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question