Jump to content

Output Files to Specific Directory with OnJobStart


Recommended Posts

I'm working on a rule to output files to a specific directory based on the letter designation on a data file. And I'm getting some odd errors that I have never got before and I'm not certain my regex is correct for what I need to do.

 

Our data files are named as the following:

20170405(A or B)_STD_(PC or DM)_record numbers-.txt

i.e. 20170405A_STD_PC_1-20000-.txt

 

I'm looking to place these in the following location:

D:\FPDirect\Submitted\RUN 20170405A\20170405A_PC_ALL

 

I started with the following code in a OnJobStart rule and it returned code 1071. I tried it in a OnRecordStart rule and it returned code 1112.

 

Here is what I am trying in the rules. I'm a novice at regex so bear with my code if it is completely wrong.

------------

FusionPro.Composition.inputFileName = '[^2[0-9][0-9][0-9][0-9][0-9][0-9][0-9]A_STD_PC_1-[0-9][0-9][0-9][0-9][0-9]-.txt$]')

 

FusionPro.Composition.outputFileFullPathName = 'D:\FPDirect\Submitted\[^RUN 2[0-9][0-9][0-9][0-9][0-9][0-9][0-9]A\2[0-9][0-9][0-9][0-9][0-9][0-9][0-9]A_PC_ALL$]'

 

Any help would be appreciated. I am using the hot folders for the new Web Services dashboard and leaving the Output File location blank.

Link to comment
Share on other sites

You don't need to use regexp matching for this. Why not just split the input file name at the underscores?

var input = GetFileName(PrimaryInputFile()).split('_');
FusionPro.Composition.outputFileFullPathName = 'D:\\FPDirect\\Submitted\\RUN ' + input[0] + '\\' + input[0] + '_' + input[2] + '_ALL\\' + ReplaceFileExtension(input.join('_'), FusionPro.Composition.outputFormatExtension);

Link to comment
Share on other sites

You don't need to use regexp matching for this. Why not just split the input file name at the underscores?

var input = GetFileName(PrimaryInputFile()).split('_');
FusionPro.Composition.outputFileFullPathName = 'D:\\FPDirect\\Submitted\\RUN ' + input[0] + '\\' + input[0] + '_' + input[2] + '_ALL\\' + ReplaceFileExtension(input.join('_'), FusionPro.Composition.outputFormatExtension);

 

Step,

Would that work for all the file names? This is a list of all the file names that I would need to compose to the correct folders:

 

20170405A_STD_DM_1-50000-.txt

20170405A_STD_DM_50001-100000-.txt

20170405A_STD_DM_100001-150000-.txt

 

Would it work for when the file name changes to a B after the run number? We alternate weeks from A to B on an 8 week cycle.

Link to comment
Share on other sites

Step,

Would that work for all the file names? This is a list of all the file names that I would need to compose to the correct folders:

 

20170405A_STD_DM_1-50000-.txt

20170405A_STD_DM_50001-100000-.txt

20170405A_STD_DM_100001-150000-.txt

 

Would it work for when the file name changes to a B after the run number? We alternate weeks from A to B on an 8 week cycle.

Yes, it would work for all of those scenarios. Here's a breakdown of what I mean by "splitting the input file name at the underscores" that may make it easier to visualize:

var input = PrimaryInputFile(); // /path/to/20170405A_STD_DM_1-50000-.txt
input = GetFileName(input);     // 20170405A_STD_DM_1-50000-.txt
input = input.split('_');       // [  '20170405A',     <--- input[0]
                               //    'STD',           <--- input[1]
                               //    'DM',            <--- input[2]
                               //    '1-50000-.txt']; <--- input[3]

As you can see, when the file name is split at the underscore, the first position in the resulting array (input[0]) will be the correct run number regardless of whether an A or B is used since it simply takes everything up until the first underscore as that value.

 

The only issue I see is that all our data file names don't have the same number of input slots.

I don't know what that means.

Link to comment
Share on other sites

Step,

Thanks again for your help.

 

The part where I said the data file names don't have the same number of input slots is because we have proof files so when I have input[0], input[2] and I added an input[3], I get 20170405A_PC_test_undefined-.txt because we don't list the record numbers in the proof file names. As long as the files list the record numbers, I don't get an _undefined in the folder name.

 

Minor annoyance but we could just change our naming of the files.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...