Sort out different pdf-page in different directions

Post Reply
lombert
Member
Posts: 166
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Sort out different pdf-page in different directions

Post by lombert »

I would like to sort the two first and two last pdf-page one way and the rest in one.



I have split up the pdf and marked the suffix of every pad with [Index] and [Total].

e.g.

TEST_01_24.pdf,

TEST_02_24.pdf to

TEST_24_24.pdf..



I will never knew how many pages there are in the pdf, so it has to take the information from the suffix or inside the pdf..



What would be the best way to solved this?
Between jobs!
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Sort out different pdf-page in different directions

Post by freddyp »

On the connection that separates the first two and the last two pages you put four conditions (separated by OR). The left-hand side of the four conditions is:



[Switch.Calculation:Expression="[Job.NameProper:Search=d{2|3}]"]



Note the Switch.Calculation which is new in update 4. It takes the expression and turns it into a number. The expression takes the first 2 or 3 digits from the name proper of the job. In your example 01, 02, ... 24, so the result is 1, 2, ... 24.



The operator is always "Equals".



The right-hand side of the comparison is:

for the first condition: 1 (of course, if it is the first page, take it)

for the second condition: 2 (what had you thought :))

for the third condition: [Switch.Calculation:Expression="[Job.NameProper:Search=d{2|3}$]-1"]

This takes the last 2 or 3 digits from the name and subtracts 1. The conversion to a number will in your example give 23 because all files are named 24 at the end. So if the left-hand side is also 23 the file will be picked up.

For the fourth condition, it is the same as for the third, but without -1.



And on the other connection you simply put "All other jobs".



Freddy
lombert
Member
Posts: 166
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Sort out different pdf-page in different directions

Post by lombert »

Hi, thanks!



I don't get it to work.. :(

All the files is going in the route that have the conditions.

I have tested files named;

01_20_TEST.pdf

01_TEST.pdf

TEST_01_20.pdf

TEST_01.pdf

No one is working..
Between jobs!
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Sort out different pdf-page in different directions

Post by dkelly »

If you have Scripting Module you can use this to separate the covers and set other connection to "all others"



var fn = job.getNameProper();

var parts = fn.split("_");

var numberOfPages = parseInt(parts[2], 10);

var pageNum = parseInt(parts[1], 10);

if (pageNum < 3 || pageNum > numberOfPages-2)

true;

else

false;



Dwight Kelly

Apago, Inc.

dkelly@apago.com
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Sort out different pdf-page in different directions

Post by freddyp »

It worked for me. It is probably just a small mistake, every character is important! Note that it will only work with TEST_01_20.pdf in your group of examples because that is what the regular expressions are searching for: the first group of two or three digits and the last group of two or three digits before .pdf.



Or, you are not using update 4. That is required as the Calculation is new in that version.



Dwight's script expression is certainly more readable, but I was trying to give a solution that does not require a script as I do not know if you have the module.



Freddy
lombert
Member
Posts: 166
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Sort out different pdf-page in different directions

Post by lombert »

Freddy, I will try it more, I'm just did some quick test from home. And it is the last version installed.



I realize that sometime there is file-name that has numbers in there name so the page-number would not be first.

How would the regular expressions look like if I just added 01, 02 in the beginning of the file-name instead?



Dwight, thanks for the script, I have the script module but is not so familiar to use script in flows, but if I understand how to use it I will try it.
Between jobs!
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Sort out different pdf-page in different directions

Post by dkelly »

Simply select "Include these files" for one of the connections and then "Define script expression". Copy and paste the script above. Done.
lombert
Member
Posts: 166
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Sort out different pdf-page in different directions

Post by lombert »

Thank you Dwight!

It worked perfect, just as I wanted it. Now I have the new flow up and running and we should see tomorrow if it works in real production..
Between jobs!
Post Reply