[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gcmd-usr] Regex replacing in Advanced Rename Tool
From: |
Piotr Eljasiak |
Subject: |
Re: [gcmd-usr] Regex replacing in Advanced Rename Tool |
Date: |
Mon, 02 Apr 2007 23:36:48 +0200 |
> when renaming files with the Advanced Rename Tool is there any way to
> reference the regex matches in the replacement text?
>
> Consider the following:
> - original name: foo4.bar
> - new name: 4foo.bar
>
> One could use the following expression:
> ^[A-Za-z]+ - to get "foo"
> [0-9] - to get "4"
> \.[A-Za-z]+ - to get "bar"
>
> Now that I have these matches, can I somehow use them in the replacement
> text? Haven't found anything in the documentation so far. Did I miss
> anything?
You think about something like:
Replace this: ^([a-zA-Z]+)([1-9][0-9]*)
With this: \2\1
right?
Unfortunately it is not possible yet... I'll add this to our TODO list,
but it won't get into gcmd before 1.2.5
But... there is a workaround for your problem:
1. file extension is accessible in template as $e
2. If you know the number of digits in advance, you can use
python-like ranges in templates, e.g. $n(0:-1) will bring you
all characters till the last one in the filename.
So in your example use template (but not regex!!!):
$n(-1:)$n(:-1).$e
to get 4foo.bar
Hope it'll help,
Piotr