Batch Text Replace from Control List Table Possible?

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
binar
Posts: 3
Joined: Thu Feb 24, 2011 4:25 am

Batch Text Replace from Control List Table Possible?

Post by binar »

Can Textpipe perform the task of batch editing 60 TEXT files driven by a control list I import into Textpipe as a CSV table file? Can it perform as outlined below:

1) Open text file (by referencing path and filename data listed in Columns A & B of the control list csv file)
2) Replace text within text file (by referencing data listed in Columns C & D of the control list csv file)
3) Save changes done to text file
4) Close the text file.
5) Move on to next text file on list until end of list is reached.

In short, I’m seeking to utilize TextPipe as a text replacer to batch edit 60 NotePad text files all controlled from a batch list I have setup within Microsoft Excel with columns named: “PATH”, “FILENAME”, “ORIGINAL TEXT”, “REPLACEMENT TEXT” (see attachment) and have exported as a CSV table file.

Any help will be immensely appreciated. Thanks.
Attachments
Sample CSV file.zip
(694 Bytes) Downloaded 404 times
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Batch Text Replace from Control List Table Possible?

Post by DataMystic Support »

Hi there,

Yes - TextPipe can do this.

You will need to write a small VBScript .vbs program to iterate through your data, and then simply automate TextPipe to open each file, apply a search/replace and then run the filter.

Code: Select all

dim TextPipeApp
dim TPWindow

Set TextPipeApp = CreateObject("TextPipe.Application")
Set TPWindow = TextPipeApp.newWindow

...loop over files here....
TPWindow.clearAllFiles
TPWindow.addFile "my file", 0, 1

TPWindow.startFilters
TPWindow.clearAllFilters
TPWindow.logEnabled = false
TPWindow.logFilename = "textpipe.log"
TPWindow.logAppend = true
TPWindow.logThreshold = 500
TPWindow.inputMode = 1
TPWindow.inputBinaryFiles = 0
TPWindow.inputBinarySampleSize = 100
TPWindow.inputPromptOnEach = false
TPWindow.inputPromptOnReadOnly = false
TPWindow.inputDeleteFiles = false
TPWindow.inputInsideCompressed = true
f1 = TPWindow.addReplaceFilter( "", "", 0, false, false, false, true, false, false, false, 0 )
TPWindow.outputMode = 1
TPWindow.outputRetainDate = false
TPWindow.outputTestMode = 0
TPWindow.outputAppend = false
TPWindow.outputOnlyOutputChangedFiles = 1
TPWindow.outputOpenOutputOnCompletion = false
TPWindow.outputExtension = ""
TPWindow.outputFolder = ""
TPWindow.outputRemoveEmpty = false
TPWindow.endFilters

if TPWindow.execute = false then MsgBox "ERROR " & vbCrLF & TPWindow.errorText
Set TPWindow = Nothing


...end looping...

Set TextPipeApp = Nothing
binar
Posts: 3
Joined: Thu Feb 24, 2011 4:25 am

Re: Batch Text Replace from Control List Table Possible?

Post by binar »

Thank you very much for your post.

Please excuse me for my lack of programming skills. I'm frankly not able to identify the difference between Vbscript and any other form of code just by looking at it.

Therefore, is the code you posted the Vbscript you mention in your post? Will this code enable TextPipe to accept my imported control file and perform all text changes to all filenames listed in my control list? I noticed there is a text line that mentions "myfile" in the script you posted. Do I need to overwrite "myfile" with the name of the CVS file I want to import? Will TextPipe Lite be able to perform this task using your script or do I have to buy the Pro version? I hope to hear back from you because I really need to find a solution to my problem. Thanks.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Batch Text Replace from Control List Table Possible?

Post by DataMystic Support »

It is a vbscript, and it is not complete - you need to get a coder (try http://www.rentacoder.com) to add code to load your file, split each line into fields, and then run TextPipe once for each line of data.
binar
Posts: 3
Joined: Thu Feb 24, 2011 4:25 am

Re: Batch Text Replace from Control List Table Possible?

Post by binar »

DataMystic Support wrote:It is a vbscript, and it is not complete - you need to get a coder (try http://www.rentacoder.com) to add code to load your file, split each line into fields, and then run TextPipe once for each line of data.

Simon,
Thanks for your post. The approach you are recommending seems to be very complex. I'm assuming you are very knowledgable regarding software designed for the purpose of replacing text automatically. Therefore, if you can allow me to probe your brain and ask you if you know of any standalone application that works in the way I have described straight out of the box? I would appreciate it a lot if I can hear back from you with any other recommendations besides TextPipe. Thanks.
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Batch Text Replace from Control List Table Possible?

Post by DataMystic Support »

The approach I am suggesting is the simplest possible approach, and I am very knowledgeable in this field.

I don't know of any product that can do this out of the box - you will have to do coding to suit your custom requirements.
Post Reply