Batch Text Replace from Control List Table Possible?

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

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

Batch Text Replace from Control List Table Possible?

Postby binar » Thu Feb 24, 2011 4:51 am

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 261 times

User avatar
DataMystic Support
Site Admin
Posts: 2162
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Batch Text Replace from Control List Table Possible?

Postby DataMystic Support » Thu Feb 24, 2011 7:41 am

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
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

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

Re: Batch Text Replace from Control List Table Possible?

Postby binar » Fri Feb 25, 2011 1:03 am

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: 2162
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Batch Text Replace from Control List Table Possible?

Postby DataMystic Support » Fri Feb 25, 2011 7:34 am

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

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

Re: Batch Text Replace from Control List Table Possible?

Postby binar » Sat Feb 26, 2011 1:23 am

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: 2162
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: Batch Text Replace from Control List Table Possible?

Postby DataMystic Support » Mon Feb 28, 2011 2:37 pm

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.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests