Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 18th, 2017, 08:22 AM
ReminderVDP ReminderVDP is offline
Regular Contributor
 
Join Date: Jan 2013
Location: King of Prussia, PA
Posts: 118
Default Output Files to Specific Directory with OnJobStart

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.
__________________
Bryan Mathes, Print Production Specialist
FusionPro Designer 9.3.36, FusionPro Producer (Server) API 9.3.36
Mac OSX 10.8.5
Mac Pro 2.8 GHz Quad Core Intel Xeon
Reply With Quote
  #2  
Old April 18th, 2017, 11:32 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Output Files to Specific Directory with OnJobStart

You don't need to use regexp matching for this. Why not just split the input file name at the underscores?
Code:
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);
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old April 18th, 2017, 11:38 AM
ReminderVDP ReminderVDP is offline
Regular Contributor
 
Join Date: Jan 2013
Location: King of Prussia, PA
Posts: 118
Default Re: Output Files to Specific Directory with OnJobStart

Quote:
Originally Posted by step View Post
You don't need to use regexp matching for this. Why not just split the input file name at the underscores?
Code:
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.
__________________
Bryan Mathes, Print Production Specialist
FusionPro Designer 9.3.36, FusionPro Producer (Server) API 9.3.36
Mac OSX 10.8.5
Mac Pro 2.8 GHz Quad Core Intel Xeon
Reply With Quote
  #4  
Old April 18th, 2017, 01:20 PM
ReminderVDP ReminderVDP is offline
Regular Contributor
 
Join Date: Jan 2013
Location: King of Prussia, PA
Posts: 118
Default Re: Output Files to Specific Directory with OnJobStart

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

Thanks for your help!
__________________
Bryan Mathes, Print Production Specialist
FusionPro Designer 9.3.36, FusionPro Producer (Server) API 9.3.36
Mac OSX 10.8.5
Mac Pro 2.8 GHz Quad Core Intel Xeon
Reply With Quote
  #5  
Old April 18th, 2017, 02:10 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Output Files to Specific Directory with OnJobStart

Quote:
Originally Posted by ReminderVDP View Post
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:
Code:
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.

Quote:
Originally Posted by ReminderVDP View Post
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.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old April 19th, 2017, 05:21 AM
ReminderVDP ReminderVDP is offline
Regular Contributor
 
Join Date: Jan 2013
Location: King of Prussia, PA
Posts: 118
Default Re: Output Files to Specific Directory with OnJobStart

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.
__________________
Bryan Mathes, Print Production Specialist
FusionPro Designer 9.3.36, FusionPro Producer (Server) API 9.3.36
Mac OSX 10.8.5
Mac Pro 2.8 GHz Quad Core Intel Xeon
Reply With Quote
  #7  
Old April 19th, 2017, 06:00 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Output Files to Specific Directory with OnJobStart

I see. You could just set that to a variable that returns an empty string when the record numbers are undefined:
Code:
var records = input[3] ? '_' + input[3] : '';
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #8  
Old April 25th, 2017, 09:31 AM
ReminderVDP ReminderVDP is offline
Regular Contributor
 
Join Date: Jan 2013
Location: King of Prussia, PA
Posts: 118
Default Re: Output Files to Specific Directory with OnJobStart

That works great. Thanks again. If I were to strip the file extension from the folder name, would that happen in the variables? I tried it in the file path and it didn't do anything.
__________________
Bryan Mathes, Print Production Specialist
FusionPro Designer 9.3.36, FusionPro Producer (Server) API 9.3.36
Mac OSX 10.8.5
Mac Pro 2.8 GHz Quad Core Intel Xeon
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:21 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.