Rename Job by Regular Expression

Post Reply
berniemok
Newbie
Posts: 7
Joined: Tue Sep 04, 2012 9:20 am

Rename Job by Regular Expression

Post by berniemok »

Just trying the example 4 in "Use regular expressions in Enfocus Switch" in Youtube.

1. For the job file "B412344_6.pdf" wants to change into B412344_p006.pdf

using "Rename Job" Element,

search : [Job.NameProper:Search="_\d{1}$"]
and replace: p00[Job.NameProper:Search="\d{1}$"]

2. For the job file "B412344_26.pdf" wants to change into B412344_p026.pdf

using "Rename Job" Element,

search : [Job.NameProper:Search="_\d{2}$"]
and replace: p0[Job.NameProper:Search="\d{2}$"]

3. I found that I can work fine if I use 2 different Rename Job Element.
( In my screen dump, Input folder "1 digit", "2 digit")

4. However, if I put them together as Action 1 for 1 digit, Action 2 for 2 digit, or vice versa. The jobs will go to problem job with error "Dynamic property "SearchFor1 (or 2)" has invalid value."
(In my screen dump, Input folder is "F_1-digit, S_2-digit" and "F_2 digit, S-digit")

So I would like to see any mistakes being made.

Thank you in advance!
Attachments
1-Flow diagram.JPG
1-Flow diagram.JPG (58.01 KiB) Viewed 3729 times
User avatar
Terkelsen
Advanced member
Posts: 297
Joined: Thu Sep 08, 2011 5:08 pm
Contact:

Re: Rename Job by Regular Expression

Post by Terkelsen »

You must understand that Action 1 is carried out before Action 2. This means that Action 1 will change the name of "B412344_26.pdf" to "B412344_p006.pdf. When Action 2 is run, the first character after the underscore is no longer a digit (it's "p") and Action 2 will do nothing:

I'm not an expert in RegEx but you will need to test for the number of digits after the underscore before carrying out the Action.
Post Reply