Page 1 of 1

Trying to amend the VBScript in a standard filter

Posted: Fri Dec 19, 2008 8:58 pm
by DM_Cal
Hello
I was trying to create a new filter based on an existing standard filter. The standard filter is 'rename files according to contents.fll'

I want to change it so that rather than it creating a 'rename' line for each line in the input I just want a file created with only one rename line (i.e if I have an input file with 5 lines I only want 1 output rename line not 5). I've tried taking out the looping part of the below script but my VBS is just not good enough and it doesn't work. Can you advise how I get this filter to create a file with only one rename command line on it? I think the section that needs changing is below but I am not sure how...

'Our filename counter
dim fileNumber
Dim fso, f1

'Called for every line in the file
function processLine(line, EOL)
recid = line

f1.WriteLine( "ren """ & TextPipe.fullInputFilename & """ """ & _
newFilename & recid & newFileExtension & """" )

processLine = line & EOL
end function

thanks

Re: Trying to amend the VBScript in a standard filter

Posted: Mon Jan 05, 2009 9:08 am
by DataMystic Support
Instead of using the processLine function, use the endFile function.
You haven't defined your new filename variable anywhere...
eg.

Code: Select all

'Our filename counter
dim fileNumber
Dim fso, f1, recid

function processLine(line, EOL)
  recid = line
  processLine = line & EOL
end function


sub startJob()
end sub


sub endJob()
end sub


function startFile()
  startFile = ""
end function


'Called before each file is closed -
'flush all pending file output here
function endFile()
  endFile = ""
  f1.WriteLine( "ren """ & TextPipe.fullInputFilename & """ """ & _
    newFilename & recid & newFileExtension & """" )
end function