Page 1 of 1

Tricky to try and explain

Posted: 2021-03-06 07:25:19
by Smokes
Hi
Bit tricky trying to ask for help with something not knowing the correct terminology.

I have a number of files with a prefix number with same file extension.


I want to keep the numbers and file extension and maybe add something more meaningful between numbers and extension.

Example
1234567 Name of file variable in length with file extension.
and
123456 only with file extension.

What would work for these?

Thanks
Smokes

Re: Tricky to try and explain

Posted: 2021-03-10 10:14:19
by antp
Hi,
Using regular expressions it is quite easy.
Use the following expression:
(\d+).*\.([^\.]+)
and the following new name template:
$1.$2
To keep only the number prefix and the extension
if you want to put additional text in the new name, you can put it after the $1

$1 and $2 matche the blocks between parenthesis
\d = number
+ = 1 or more
* = 0 or more
. = any character
\. = an actual dot character
[^\.] = anything except a dot