Extract string from filename to variable
Extract string from filename to variable
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.
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
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.
You can write those values to private data using Metatagger in the app store.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Extract string from filename to variable
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"]
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
... or for renaming you could use:
Keep segment
Act on: Filename proper
Start index: 8
End index: 0
Keep segment
Act on: Filename proper
Start index: 8
End index: 0
Re: Extract string from filename to variable
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\ ?
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
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'.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)
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Extract string from filename to variable
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?


And this is my current flow:

Last edited by Indy2 on Tue Jul 12, 2016 12:11 am, edited 1 time in total.
Re: Extract string from filename to variable
I see. Yeah, use Segment. [Job.Name:Segment="8-10"]
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Extract string from filename to variable
Thanks, that does return the expected sample value.I see. Yeah, use Segment. [Job.Name:Segment="8-10"]
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
Can you provide a screenshot or show the values of your set hierarchy path?
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Extract string from filename to variable
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
Thanks, that did the trick!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.
