Page 1 of 1

DYNAMIC FILENAMES

Posted: Fri Aug 21, 2009 2:42 pm
by NPPI_Active
I have a fll that adds a file header from another file. Sweet.

I now have a situation where I have the file being loaded is "A<<NAME_X>>.txt" and I want to load "H<<NAME_X>>.txt" from the same folder.

So the folder contains:
AFred.txt
ABarney.txt
HFred.txt
HBarney.txt

And I want AFred.txt to load HFred.txt as a header and the same for ABarney.txt loading HBarney.txt but i dont want to create 2 filters! I want one filter to recognise which file is being used and then apply the correct header. One filter! Please tell me its possible........

Re: DYNAMIC FILENAMES

Posted: Mon Aug 24, 2009 9:41 pm
by DataMystic Support
Try this:

Load Fred into an environment variable, and change the 'header' filename to refer to that env var, e.g. c:\H%NAME%.txt

Code: Select all

In a batch file:
set NAME=Fred
textpipe.exe /f=myfilter.fll A%NAME%.txt /g /q
set NAME=Barney
textpipe.exe /f=myfilter.fll A%NAME%.txt /g /q
You can also script the whole lot from vbscript e.g.

Code: Select all

VBScript:
Set vb_TextPipeApp = CreateObject("TextPipe.Application")
Set vb_TPWindow = vb_TextPipeApp.newWindow
loop here over all names
  TPWindow.clearAllFiles
  TPWindow.addFile "A<name>.txt", 0, 1
  TPWindow.clearAllFilters
  f1 = TPWindow.addStringFilterFile( 19, "H<name>.txt", false )
  vb_TPWindow.execute
  

Re: DYNAMIC FILENAMES

Posted: Thu Sep 03, 2009 12:56 am
by NPPI_Active
Used the Environment variable solution. Works a treat.

Thanks! :D