Page 1 of 1

Extract string from filename to variable

Posted: Sat Jul 09, 2016 5:30 am
by Indy2
I'm sure this should be quite an easy thing to accomplish but can't quite figure out how.

We have incoming files in the following format.

000000_100_filename.pdf

Where 000000 is the jobid and 100 is the file version.

How can I extract the jobid and set it as a variable so the file can be places in the correct folder?
Ex. 123456_100_cover.pdf would need to go to \\servername\data\123456\100_cover.pdf

Before I forget, we currently don't have the scripting module.

Re: Extract string from filename to variable

Posted: Sun Jul 10, 2016 4:42 pm
by gabrielp
It's not easy without Scipter or without changing the file name structure. But this could work: [Job.Name:Segment="8-10"]

You can write those values to private data using Metatagger in the app store.

Re: Extract string from filename to variable

Posted: Mon Jul 11, 2016 1:48 pm
by Terkelsen
If all you need do is to place the file in the right folder you could just use the "Set hierarchy path" element followed by a rename.

Set hierarchy path.
Path segment 1: Servername
Path segment 2: Data
Path segment 3: [Job.NameProper:Before="_"]
Path segment 4: [Job.NameProper:Search="8-10"]

... and then rename the file with this

Replace, Filename proper with this: [Job.NameProper:Segment="8-50"]

Re: Extract string from filename to variable

Posted: Mon Jul 11, 2016 2:00 pm
by Terkelsen
... or for renaming you could use:

Keep segment
Act on: Filename proper
Start index: 8
End index: 0

Re: Extract string from filename to variable

Posted: Mon Jul 11, 2016 9:55 pm
by Indy2
I'm trying to get it to work using the set hierarchy path as you suggested but it's not quite working as yet.

A few questions;

- What is [Job.NameProper:Search="8-10"] supposed to do?
It doesn't return a sample value like [Job.NameProper:Before="_"] does (000000 in this case)

- input and output folder.
My input folder is the incoming files folder.
But what would the output folder be (Auto-managed?) as it would be constructed by the set hierarchy path, or \\servername\data\ ?

Re: Extract string from filename to variable

Posted: Mon Jul 11, 2016 10:05 pm
by gabrielp
Indy2 wrote: - What is [Job.NameProper:Search="8-10"] supposed to do?
It doesn't return a sample value like [Job.NameProper:Before="_"] does (000000 in this case)
It should do the same thing. It should return a string with the value of the original name proper, from character 8 to character 10. In the original file name you sent, it would return '100'.

Re: Extract string from filename to variable

Posted: Tue Jul 12, 2016 12:05 am
by Indy2
It should do the same thing. It should return a string with the value of the original name proper, from character 8 to character 10. In the original file name you sent, it would return '100'.

OK, using [Job.NameProper:Search="8-10"] returns no sample value. Could the syntax be incorrect?

Image
Image

And this is my current flow:
Image

Re: Extract string from filename to variable

Posted: Tue Jul 12, 2016 12:10 am
by gabrielp
I see. Yeah, use Segment. [Job.Name:Segment="8-10"]

Re: Extract string from filename to variable

Posted: Tue Jul 12, 2016 12:19 am
by Indy2
I see. Yeah, use Segment. [Job.Name:Segment="8-10"]
Thanks, that does return the expected sample value.

What I can't figure out yet is what the output folder should be.
I.e. the file goes through, gets renamed but doesn't show up in the order-ID folder.

Re: Extract string from filename to variable

Posted: Tue Jul 12, 2016 3:16 am
by gabrielp
Can you provide a screenshot or show the values of your set hierarchy path?

Re: Extract string from filename to variable

Posted: Tue Jul 12, 2016 8:42 am
by Terkelsen
In order to use the information added by "Set Hierarchy Path" your output folder needs to be an Achieve hierarchy. So exchange your "Folder 6" with an Archive hierarchy and make sure to set the "Subfolder levels" to a number high enough.

Re: Extract string from filename to variable

Posted: Tue Jul 12, 2016 12:06 pm
by Indy2
In order to use the information added by "Set Hierarchy Path" your output folder needs to be an Achieve hierarchy. So exchange your "Folder 6" with an Archive hierarchy and make sure to set the "Subfolder levels" to a number high enough.
Thanks, that did the trick! :D