Output to a folder based on the file name

I am not how to do this. I have a process set up and the output is a pdf. That’s fine. I need to take that pdf and put it in a folder based on file name. For example -

pdf names = abc_123456, abc_789321
folder names = 10547821 and 10854954
Pdf file abc_123456 needs to go into folder 10854954
Pdf file abc_789321 needs to go into folder 10547821

My original input data is xml. I do have a csv file with 400 folders names and which files need to go into what folder. Its basically two columns. Column one = 123456, Column two = 10854954 and so on.

How can I get the pdf’s in the corresponding folders?


You could load up the CSV file into Workflow’ Data repository. Then use that to check on the filename to know which folder to use.

How do you create your pdf? If you have the corresponding folder name for the output pdf in xml you can directly write to that folder!?

If you create the pdf files in Connect you can use the folder name per record as metadata in the filename mask (e.g. ${segment.metadata.column2}/${segment.metadata.column1}.pdf). Of course you have to select absolute path at output folder.

That is my problem. I do not have Column two (folder name) but I do have Column One to name the pdf. I have a separate .csv file that has the file name to folder name mapping.

OK - I am back at this. I have created the Workflow Data repository and the script to query the rows. Below is what I get.


What I need is -
My pdf is named 408b2_{BPANbr}.pdf
What I need to do is get the GeminiFolder that corresponds to the BPANbr in the name of pdf so I can out the pdf to the folders set up using the Gemini folder name.

Not sure how to get there.

Thank You

First you should read this and this

Then come back with your question.

OK - I have it so that it returns one value based on the condition below
var geminiNbr = repoObject.GetKeySets(“TPA_GeminiFolders”,’[“GeminiFolder”]’,“BPANbr = ‘120330’”)

results - [{“GeminiFolder”:“1012024097”}]

How would I do this based on the pdf file name ( 408b2_123456.pdf ) where the 123456 is the BPANbr.


Now that you have your returned value, which is a JSON, in a script, parse the JSON value and get the value for GeminiFolder into a Workflow variable.

Here’s a quick way of extracting the BPANbr value from the filename (assuming all your filenames use the same structure: xxxx_yyyy.pdf):

var fName = Watch.GetJobFileName();
var BPANbr = fName.match(/(?:.*_)(\d+)(?:\.pdf)/i)[1];

Note that you may have to use Watch.GetOriginalFileName() if the job file uses a temporary name.