Trying to amend the VBScript in a standard filter

Get help with installation and running here.

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

Post Reply
DM_Cal
Posts: 10
Joined: Thu Oct 18, 2007 9:08 pm

Trying to amend the VBScript in a standard filter

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

Re: Trying to amend the VBScript in a standard filter

Post 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
Post Reply