Heirarchy from Job Origin

Post Reply
johnpanton1
Newbie
Posts: 2
Joined: Sun Jul 27, 2014 6:45 pm

Heirarchy from Job Origin

Post by johnpanton1 »

I am facing a small issue with the Heirarchy from Job Origin functionality in Switch 12



The problem comes in when you have a Mac Switch server for example but some clients are on PC.



The job ticket variable from a PC client would contain for example the mapped drive letter and backslashes e.g. j:folder1folder2filename.pdf



from a Mac it would be Volume Name/folder1/folder2/filename.pdf



There is no standard functionality to resolve this in switch, making this feature almost useless in a cross platform environment.



We have been building a flow that relies on tis being able to work, but have found no solution to date.

Does anyone know of a solution or have a script to be able to handle this.


dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Heirarchy from Job Origin

Post by dkelly »

It would require a script expression or full script element to resolve the names.



The only functions that Switch has for dealing with platform specific paths is for converting directory separators: File.toNativeSeparators(), File.fromNativeSeparators and Dir.convertSeparators().
johnpanton1
Newbie
Posts: 2
Joined: Sun Jul 27, 2014 6:45 pm

Heirarchy from Job Origin

Post by johnpanton1 »

would "File.to Native Separators" not work in such a case ?



Effectively the Volume and of drive letter is not important, I only need the last part of the Origin path to set a new Hierarchy path, so effectively I need to change to /.



Are you saying this can be done without a Script ?
freddyp
Advanced member
Posts: 413
Joined: Thu Feb 09, 2012 3:53 pm

Heirarchy from Job Origin

Post by freddyp »

toNativeSeparators() would have to be part of a script (expression) anyhow, so you will not be able to avoid that.



There is one "tricky" thing: you would expect to be able to use job.getOrigin(), but that function does not exist. The job's origin is namely part of the OccurrenceList. The script expression will probably have to look like this:





var re = //g;

var occurrences = job.getOccurrences();

var origin = occurrences.at(0).getOrigin();

s.log(3,"Origin : "+origin);

"Volume name/"+origin.substring(3).replace(re,"/");





I wrote "probably" because I did not test this. I therefore added the s.log(3,.. which will show an error message in the Messages so you can check that the actual origin string is correct. Let me know. If it is correct, it is best to remove that line. If it is not I will have to recreate your setup to reproduce this.



I am not using toNativeSeparators() here, but doing a straight string replacement as I am manipulating the origin string anyhow to get rid of the drive letter.



Freddy
Post Reply