Extract string from filename to variable

Post Reply
Indy2
Newbie
Posts: 13
Joined: Mon Jun 22, 2015 12:52 pm

Extract string from filename to variable

Post 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.
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Extract string from filename to variable

Post 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.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
User avatar
Terkelsen
Member
Posts: 126
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Extract string from filename to variable

Post 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"]
User avatar
Terkelsen
Member
Posts: 126
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Extract string from filename to variable

Post by Terkelsen »

... or for renaming you could use:

Keep segment
Act on: Filename proper
Start index: 8
End index: 0
Indy2
Newbie
Posts: 13
Joined: Mon Jun 22, 2015 12:52 pm

Re: Extract string from filename to variable

Post 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\ ?
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Extract string from filename to variable

Post 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'.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Indy2
Newbie
Posts: 13
Joined: Mon Jun 22, 2015 12:52 pm

Re: Extract string from filename to variable

Post 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
Last edited by Indy2 on Tue Jul 12, 2016 12:11 am, edited 1 time in total.
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Extract string from filename to variable

Post by gabrielp »

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
Indy2
Newbie
Posts: 13
Joined: Mon Jun 22, 2015 12:52 pm

Re: Extract string from filename to variable

Post 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.
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Extract string from filename to variable

Post by gabrielp »

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
User avatar
Terkelsen
Member
Posts: 126
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Extract string from filename to variable

Post 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.
Indy2
Newbie
Posts: 13
Joined: Mon Jun 22, 2015 12:52 pm

Re: Extract string from filename to variable

Post 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
Post Reply