Page 1 of 1

Rename PDF with regular expressions

Posted: Wed Dec 23, 2015 8:49 am
by pargorner
Hi

I have pdf´s that I need to rename at output. Actually I just need to remove a segment within the name.
Usually the files are named with this syntax:
S60_15w46_V1_DEde.pdf
But there can be variations in the first segment:
XC60_15w46_V1_DEde.pdf
V60CC_15w46_V1_DEde.pdf
(There can alos be variations in the digits and country code, but not in length)
And I need to remove the ”_V1_” from the filename. And replace it with just a ”_". Or just remove "V1_".

I know how to match the whole name with regular expressions.
([A-Za-z0-9]*)_([0-9][0-9])w([0-9][0-9])_V([0-9])_([A-Z][A-Z])([a-z][a-z])\.(pdf|PDF)

And the first segment:
([A-Za-z0-9]*)_([0-9][0-9])w([0-9][0-9])
V60CC_15w46_V1_DEde.pdf

And also the last segment:
(([A-Z][A-Z])([a-z][a-z])\.(pdf|PDF))
XC60_15w46_V1_DEde.pdf

But I can not figure out how to use the two segments in the output name.

Any suggestions?

Thanks.

Re: Rename PDF with regular expressions

Posted: Wed Dec 23, 2015 2:37 pm
by gabrielp
If you can script, you can easily get the values of your regular expression like this: http://forum.enfocus.com/viewtopic.php? ... .cap#p4096

Again, if you can use scripter, the easiest way is to write your new name into private data then pass it into a rename configurator.

Re: Rename PDF with regular expressions

Posted: Mon Dec 28, 2015 8:34 am
by pargorner
Hi

Thanks for your reply, and that looks like a nice solution.
But I don't have the script module.

/P

Re: Rename PDF with regular expressions

Posted: Mon Dec 28, 2015 1:59 pm
by pargorner
Hi again.

I found a solution after some heavy googling and some testing.
I used the Rename Job configurator and a two action step in properties where I select the two parts I needed.
Action 1 renames and action 2 adds a prefix by selecting last part then first part with regex.

Cheers

/Pär

Re: Rename PDF with regular expressions

Posted: Mon Jan 04, 2016 9:22 am
by Terkelsen
If what you are removing is always "_V1_" you could just use the "search and replace" in the rename configurator. Search for "_V1_" and replace with "_".

Re: Rename PDF with regular expressions

Posted: Mon Jan 04, 2016 9:28 am
by pargorner
That would work. But I forgot to mention that the number in "_V1_" also varies.

Re: Rename PDF with regular expressions

Posted: Tue Jan 05, 2016 11:09 am
by Terkelsen
I think you could still use Search and Replace.

Search for: _V([0-9])_ (as regular expression)
Replace with: _ (Inline value)

Re: Rename PDF with regular expressions

Posted: Thu Jan 07, 2016 10:38 am
by pargorner
Yes, that works perfectly now.

I think I was trying to do just that when I started to solve this problem.
But I wasn't really familiar with the rename configurator. Now I am...

Thanks.