Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Script to create import file

Posted on 2013-05-24
2
Medium Priority
?
295 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 1500 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

604 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