Rename job object/regex renaming question

Post Reply
jsmith.nwadg
Newbie
Posts: 2
Joined: Fri Feb 09, 2024 3:37 pm

Rename job object/regex renaming question

Post by jsmith.nwadg »

Hi - I have a pdf where the filename format looks like this: LPLEC20240207B01CO.pdf - where the B01 is indicating a secton and page number. I am wanting to rename these files so they will be part of the A section tacked onto the end of the existing A section, which is (and will always be) 8 pages, so B01 would become A09, etc. - how do I accomplish this with the rename job tool? I know it should just be a simple replacement of B with A and an addition of 8 to the page number. I get that B\d\d should match to replace the B with an A, but hw do I add 8 to the page number? Thanks
-josh
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Re: Rename job object/regex renaming question

Post by freddyp »

In the "Search and replace" action of "Rename job" you choose a private data key, say "search", for the "Search for" property and another private data key named "replace" (perhaps?) for the "Replace by" property. That makes the rename easy, now we just have to make sure we have these two pieces of private data with the correct values. For those who might not know this: private data keys can be added on most folders.

The value of the "search" private data key is easy: [Job.NameProper:Search="B\d\d"].

The value of the "replace" private data key is also easy if we base ourselves on "search" for that: A[Job.PrivateData:Key="search",Search="\d\d"]. Yes, but this turns B01 into A01. With Switch.Calculation, however, we can do arithmetic on strings: A[Switch.Calculation:Expression="[Job.PrivateData:Key="search",Search="\d\d"]+8"]. Yes, but this turns B01 into A9, not A09.

There is some convoluted way of adding leading zeroes, but what I would here is add 2 "Rename job" elements with a condition for routing, one for the cases where adding a leading zero is required, and one for "All other jobs". It is only for B01 and B02 that you have to add a leading zero: A0[Switch.Calculation:Expression="[Job.PrivateData:Key="search",Search="\d\d"]+8"] so building the condition is not that difficult: [Job.NameProper] matches B0[1|2]
jsmith.nwadg
Newbie
Posts: 2
Joined: Fri Feb 09, 2024 3:37 pm

Re: Rename job object/regex renaming question

Post by jsmith.nwadg »

Alright...I tried this several different ways and it didn't work. So I went and changed the rear brake caliper on my car, and tried again - and again no success. So I assembled a 12U wallmount rack and gave it anoither shot, and now it seems that I've managed to get it to do SOMEthing - It names everything LPLEC<date here>A8CO.pdf that I feed it. PROGRESS! At least it does SOMETHING besides send me a bunch of administrator alerts. So to get down to brass tacks, here is what I have set up - first the relevant portion of The Flow:

Code: Select all

Test Input ---> Rename for LR NX(folder) ---> Rename Job (app) --> Folder 27 (test output folder)\
In the 'Rename for LR NX folder I have 'Set Job Private Data;' as 'Multi-Line text with Variables defined' the contents of which are as follows:

Code: Select all

search=[Job.NameProper:Search="B\d\d"]
replace=A[Switch.Calculation:Expression="[Job.PrivateData:Key="search",Search="\d\d"]+8"]
...and in the 'Rename Job' app I have set the following:

Code: Select all

Action 1		Search and replace
Act on		Filename proper
Search for		Single-line text with variables defined
Replace by	Single-line text with variables defined
Repeat		Consecutive
...where 'Search for' contains [Job.PrivateData:Key="search"] and 'Replace with' contains [Job.PrivateData:Key="replace"].

Where have I gotten off track here? I'm figuring I have everything correct excpet for some arcane formatting requirement, as usual, and Switch just can't grok my odd dialect.

OH YEAH it probably matters and I should have probably mentioned this at the outset, but this is Switch 18 update 3 in case it matters. Thanks for your help!
-josh
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Re: Rename job object/regex renaming question

Post by freddyp »

Here is a flow with a solution:
Rename regex.sflow.zip
(19.35 KiB) Downloaded 142 times
Post Reply