Rename Search & Replace with Regex Help

Post Reply
Arthur
Member
Posts: 114
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Rename Search & Replace with Regex Help

Post by Arthur »

Hi there;
Trying to sort renaming with Regex and stuck with one step I simply cannot get to work, although all the regex validators are showing this to be correct and working.

Test string:

10. filename.ext

Regex search:
^((\d{2})\.(?=\s))
or
(^(\d{2}\.)(?=\s))
or whatever else that is returning the '10.' from the string above or just the dot

Replace with:
\100
which would give it 10.00 filename.ext

The fact that lookbehind neither positive nor negative is not supported, does not help either.

Could someone help with this, what am I doing wrong ??
loicaigon
Advanced member
Posts: 378
Joined: Wed Jul 10, 2013 10:22 am

Re: Rename Search & Replace with Regex Help

Post by loicaigon »

I am not sure you are doing something wrong. I did some experiments here

Search:
(.+?\.)(.+)

Replace
$100$2

That doesn't work neither when it should.

If you have Metadata module, it's easy to recombine the string. Same stands with the scripting module.

Hoping there is some way
Arthur
Member
Posts: 114
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Re: Rename Search & Replace with Regex Help

Post by Arthur »

If it was only about this one type of string I probably would, but basicly what I am trying to achieve is to get all different types of naming conventions starting with numerical sections / hierarchy description, to end up compliant with 00.00 filename.ext mask.

so basicly all the
1 filename
10 filename
10. filename
1.1 filename
1.1. filename
10.1. filename
etc.

they all shall in the end be renamed to match the mask as per the above - 00.00 filename.ext (keeping they referenced hierarchical section as indicated in the initial filename).
As I have got sometimes tens or hundreds of files to merge together in a specific order as per sections they belong to.
The sections are then divided with dividers/tabs that go in between them and make for a section start, so effectively they need to have the same numbering mask applied with only 1 addition of an '_' between the hierarchical number and the filename (in the FilenameProper) and a suffix (ie: 00.00_filename_divider.ext).
So all together then need to be sorted in the order of a FilenameProper and merged together. Sometimes such publication can comprise few thousand pages....

So I designed a flow with several steps checking the name and adding zeroes or dots where needed, but unfortunately the queried Regex does not seem to work :(
I do not have script module.
Would this then be a bug, to be reported, that what comes as obvious does not work ??
enfocus
Newbie
Posts: 14
Joined: Fri May 12, 2017 9:10 am

Re: Rename Search & Replace with Regex Help

Post by enfocus »

When you have an active maintenance contract for Switch, then you can request help for any issue you have with Switch. If you see something which behaves differently then what you expect and what is described in the documentation, then it is a good idea to report it to Enfocus Support. If it is a bug, then the support team is notified and can have it fixed in a future version. If they don't think it is a bug they can explain the current behavior. In both cases they can help to search for an alternative solution.

You can contact Enfocus Support via the support portal:
http://enfocus.com/supportportal
Arthur
Member
Posts: 114
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Re: Rename Search & Replace with Regex Help

Post by Arthur »

perfect. Thank you for your suggestions.
I will definitely have this in mind should I experience any more troublesome issues.
This one however I resolved, although I must admit that the Regex Syntax / Flavour seems a bit different to what is common elsewhere.
But I finally got it working.
loicaigon
Advanced member
Posts: 378
Joined: Wed Jul 10, 2013 10:22 am

Re: Rename Search & Replace with Regex Help

Post by loicaigon »

Andrew,
if you got it working, it's nice to share ;)
Post Reply