Creating multiple files based on a list

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

Posts: 1
Joined: Tue Mar 20, 2012 7:01 pm

Creating multiple files based on a list

Postby howardphillis » Tue Mar 20, 2012 7:11 pm


I have a single HTML file and I would like to search for a value in that file, replace that value with the first line from a different text file, save the file with a new filename (the same as the value that I added) and then keep repeating this process through the subsequent lines in my text file.

So, for example I have original-file.html and a text file with value1, value2, value3, value4, etc each on a separate line. I need to create value1.html, value2,html, value3.html, value4.html and in each of those files I need to replace <span>original-file</span> with <span>value1</span>, <span>value2</span>, <span>value3</span>, <span>value4</span>

How do I do this in TextPipe?

Many thanks


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

Re: Creating multiple files based on a list

Postby DataMystic Support » Wed Mar 21, 2012 10:06 am

Since you can't change the output file yourself during a job, the best way is to automate TextPipe from a scripting language.

The script below gives the main structure, you just need to add code to load your list, and then run the filter once for each line in the file.

Code: Select all

dim f1
'The global TextPipe Application object
dim TextPipeApp
'The global TextPipe Filter Window
dim TPWindow

sub vb_connectTextPipe()

  on error resume next
  Set TextPipeApp = CreateObject("TextPipe.Application")

  if Err.Number <> 0 then
    MsgBox "TextPipe Pro is not installed." & vbCrLF & _
      vbCrLf & _
      "Please download and install it from" & vbCrLF & _
      "", _
      vbExclamation + vbOkOnly, _
      "TextPipe Pro needs to be installed"
  end if
  Set TPWindow = TextPipeApp.newWindow

end sub

'disconnect from TextPipe
sub vb_disconnectTextPipe()

  if isObject( TPWindow ) then
    Set TPWindow = Nothing
  end if

  if isObject( TextPipeApp ) then
    Set TextPipeApp = Nothing
  end if

end sub


TPWindow.logEnabled = false
TPWindow.logFilename = "textpipe.log"
TPWindow.logAppend = true
TPWindow.logThreshold = 500
TPWindow.inputMode = 1
TPWindow.inputBinaryFiles = 1
TPWindow.inputBinarySampleSize = 100
TPWindow.inputPromptOnEach = false
TPWindow.inputPromptOnReadOnly = false
TPWindow.inputDeleteFiles = false
TPWindow.inputInsideCompressed = false

f1 = TPWindow.addReplaceFilter( "your constant string", "variable string", 4, false, false, false, false, false, false, false, 0 )

f1 = TPWindow.setPerl( 4096, false, false, true, false )
TPWindow.outputMode = 2
TPWindow.outputMergeFile = "c:\variable string.txt"

'File List:
TPWindow.addFile "", 0, 1

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



Simon Carter, - Insulin dose calculator for Type 1 diabetes - 250,000 free software downloads - send huge email attachments

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

Who is online

Users browsing this forum: No registered users and 10 guests