Rename PDF with regular expressions

Post Reply
pargorner
Newbie
Posts: 19
Joined: Mon Jan 10, 2011 4:19 pm

Rename PDF with regular expressions

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

Re: Rename PDF with regular expressions

Post 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.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
pargorner
Newbie
Posts: 19
Joined: Mon Jan 10, 2011 4:19 pm

Re: Rename PDF with regular expressions

Post by pargorner »

Hi

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

/P
pargorner
Newbie
Posts: 19
Joined: Mon Jan 10, 2011 4:19 pm

Re: Rename PDF with regular expressions

Post 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
User avatar
Terkelsen
Advanced member
Posts: 300
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Rename PDF with regular expressions

Post 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 "_".
pargorner
Newbie
Posts: 19
Joined: Mon Jan 10, 2011 4:19 pm

Re: Rename PDF with regular expressions

Post by pargorner »

That would work. But I forgot to mention that the number in "_V1_" also varies.
User avatar
Terkelsen
Advanced member
Posts: 300
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Rename PDF with regular expressions

Post by Terkelsen »

I think you could still use Search and Replace.

Search for: _V([0-9])_ (as regular expression)
Replace with: _ (Inline value)
pargorner
Newbie
Posts: 19
Joined: Mon Jan 10, 2011 4:19 pm

Re: Rename PDF with regular expressions

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