Use wildcards in set hierarchy

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

Use wildcards in set hierarchy

Post by lombert »

Hi



I need to find any way to put a file in a folder there I only knew some of the name.



Like this;



Folder is named 123456-1_abcd..

And I only knew the 123456-1 part.



So I tryed to set the hierarchy to that, but then it makes a new folder with that name. How can I match the two?
Between jobs!
dkelly
TOP CONTRIBUTOR
Posts: 658
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Use wildcards in set hierarchy

Post by dkelly »

I implemented something similar in Javascript by enumerating the directories and doing partial name matching. Not sure you can do that with Archive Hierarchy directly.
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Use wildcards in set hierarchy

Post by freddyp »

No, "Archive hierarchy" will indeed not do this directly. Nor should it. "Archive hierarchy" places the job in whatever path is in the Hierarchy attribute at that point in time. So, what you need to do is make sure that the Hierarchy contains the correct values. It is perfectly possible to do what you want, but it will indeed require a script expression somewhere to add the correct part to the hierarchy path.



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

Use wildcards in set hierarchy

Post by lombert »

Ok. Thanks for the answer.



How can that solution look like? I will always have the first section, in the filename or in the meta data, but the second part is not possible to get until It's time to put the file in the folder.
Between jobs!
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Use wildcards in set hierarchy

Post by freddyp »

Not tested, but here is what the script expression could look like. Of course you will have to set the path to the directory and you may want to return something else when the folder is not there; that is up to you. The script expression goes in a "Set hierarchy path" at the place and with the other settings you require to get the correct path.



var folder = new Dir("/path/to/folder/where/destination/is");

var dirList = folder.entryList("*",Dir.Dirs,Dir.Name);

var destinationFolder = "";

for (var i=0; i<dirList.length; i++) {

if (dirList.startsWith(job.getNameProper()) == true) {

destinationFolder = dirList;

}

}

destinationFolder;
lombert
Member
Posts: 167
Joined: Fri Feb 04, 2011 2:31 pm
Location: Sweden

Use wildcards in set hierarchy

Post by lombert »

Thanks!



It worked just perfect. I had to rename my files to just the correct "folder name", the first 123456-1 part, then the file finds the right folder (123456-1_abcd)..



If the folder is'n there, the file just lays outside the folders.. But that should not be any problem, the folder should be there.
Between jobs!
Post Reply