Solved

Script to create import file

Posted on 2013-05-24
2
289 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now