hierarchy path

Post Reply
kmcrae
Member
Posts: 23
Joined: Wed Feb 23, 2011 2:49 am

hierarchy path

Post by kmcrae »

Hi,

how can use hierarchy path with three first digit (is the page number) of file for download on the good folder match?!!

101_CAT2016_CLUB_FRNET.pdf ------> CAT16_CX_ANDET_MachineConsumables_100-118
102_CAT2016_CLUB_FRNET.pdf ------> CAT16_CX_ANDET_MachineConsumables_100-118

228_CAT2016_CLUB_FRNET.pdf ------> CAT16_CX_ANNET_OfficeSupplies_209-262
229_CAT2016_CLUB_FRNET.pdf ------> CAT16_CX_ANNET_OfficeSupplies_209-262


Help Thank!!
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: hierarchy path

Post by sander »

I'm not quite sure what you mean.

Do you want to move e.g. the file 101_CAT2016_CLUB_FRNET.pdf to folder CAT16_CX_ANDET_MachineConsumables_100-118?

And due to 101 in the filename, it is in range 100-118 and needs to be moved to that folder? Correct?
kmcrae
Member
Posts: 23
Joined: Wed Feb 23, 2011 2:49 am

Re: hierarchy path

Post by kmcrae »

yes that i want!!
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: hierarchy path

Post by sander »

Is there a way to indentify the destination folder, is it somehow attached as metadata to the file?

If not, I'll go for a script expression in your path segment, which will check if the first 3 digits in the filename are 101 to 118 then set path segment to CAT16_CX_ANDET_MachineConsumables_100-118, if 228-262 set to CAT16_CX_ANNET_OfficeSupplies_209-262 etc.

But, in my opinion, this is only good manageable if these folders don't change (e.g. for every order) and there's not a couple of 100 of them.
kmcrae
Member
Posts: 23
Joined: Wed Feb 23, 2011 2:49 am

Re: hierarchy path

Post by kmcrae »

the best solution is the script expression but i don't no create the script!? can you with the script?
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: hierarchy path

Post by sander »

Use this as your script expression in your Set hierarchy path;

Image

Code: Select all

// Set first three charachters of jobName as variable pageNumber
var pageNumber		= job.getVariableAsNumber("[Job.Name:Segment=\"1-3\"]");

// Default path is Unknown, in case of non defined
var hierarchyPath		= "Unknown";

switch (true) {
	case (pageNumber >= 100 && pageNumber <= 118):    				// Check if pageNumber is equal or greater than 100, and equal or less than 118
	hierarchyPath = "CAT16_CX_ANDET_MachineConsumables_100-118";	// Set path to CAT16_CX_ANDET_MachineConsumables_100-118
	break;
	
	case (pageNumber >= 209 && pageNumber <= 262):					// Same here, check if pageNumber is equal or greater than 209, and equal or less than 262
	hierarchyPath = "CAT16_CX_ANNET_OfficeSupplies_209-262";  		// Set path to CAT16_CX_ANNET_OfficeSupplies_209-262
	break;
}

hierarchyPath;
Result:
Image

Hope it helps,
kmcrae
Member
Posts: 23
Joined: Wed Feb 23, 2011 2:49 am

Re: hierarchy path

Post by kmcrae »

WOW its work and with this sample script enlighten me in my learning!! thank!
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: hierarchy path

Post by sander »

No problem, glad I could help you out!
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: hierarchy path

Post by sander »

Hm, somehow I copied a slightly different code as I wanted it to be.

Code: Select all

// Set first three charachters of jobName as variable pageNumber
var pageNumber		= job.getVariableAsNumber("[Job.Name:Segment=\"1-3\"]");
var hierarchyPath;


switch (true) {
	case (pageNumber >= 100 && pageNumber <= 118):    				// Check if pageNumber is equal or greater then 100, and equal or less then 118
	hierarchyPath = "CAT16_CX_ANDET_MachineConsumables_100-118";	// Set path to CAT16_CX_ANDET_MachineConsumables_100-118
	break;
	
	case (pageNumber >= 209 && pageNumber <= 262):					// Same here, check if pageNumber is equal or greater then 209, and equal or less then 262
	hierarchyPath = "CAT16_CX_ANNET_OfficeSupplies_209-262";  		// Set path to CAT16_CX_ANNET_OfficeSupplies_209-262
	break;
	
	default:
	hierarchyPath		= "Unknown";										// Default path is Unknown, in case of non defined
	break;
}

hierarchyPath;
Added default: in the switch case, so it defaults the 'correct' way.
bens
Advanced member
Posts: 253
Joined: Thu Mar 03, 2011 10:13 am

Re: hierarchy path

Post by bens »

That's an interesting use of a switch statement. Any reason you don't use an if/else?

Code: Select all

var pageNumber = job.getVariableAsNumber("[Job.Name:Segment=\"1-3\"]");
var hierarchyPath = "Unknown";

if (pageNumber >= 100 && pageNumber <= 118)
    hierarchyPath = "CAT16_CX_ANDET_MachineConsumables_100-118";
else if (pageNumber >= 209 && pageNumber <= 262)
    hierarchyPath = "CAT16_CX_ANDET_MachineConsumables_100-118";

hierarchyPath;
sander
Advanced member
Posts: 276
Joined: Wed Oct 01, 2014 8:58 am
Location: The Netherlands

Re: hierarchy path

Post by sander »

Not really, based on my experience so far.
My Switch experience, and with that Javascript / Switch scripting, is nearly over a year by now. Once when I had to do a compare with like 10 values I came up with the thoughts it is not efficient to check e.g. 9 if's before I reach if 10. That's why I used switch. It looked faster to me, however since I am learning through reading the manual and minimalize Googling scripting solutions it might not be the best way.
So all based on my own logic, and with this topic issue I notice, by automatism, I go with switch right away. If, else if, it doesn't sound bad in this case haha.

In this particular case, the only other thing I can lie off; I think it's better readable ;-)
Post Reply