DYNAMIC FILENAMES

Get help with installation and running here.

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

Post Reply
NPPI_Active
Posts: 4
Joined: Fri Aug 21, 2009 2:12 pm

DYNAMIC FILENAMES

Post 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........
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: DYNAMIC FILENAMES

Post 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
  
NPPI_Active
Posts: 4
Joined: Fri Aug 21, 2009 2:12 pm

Re: DYNAMIC FILENAMES

Post by NPPI_Active »

Used the Environment variable solution. Works a treat.

Thanks! :D
Post Reply