You are not logged in.
Hi,
I try to do something, but no way to find.
Let's say that I have this kind of files:
"title.text1.text2.extension"
but I also can have this:
"title.text1.text2.text3.extension"
What I want to do it is to delete the last part behind the dot (without the extension).
So my result will be:
"title.text1.extension" for "title.text1.text2.extension"
"title.text1.text2.extension" for "title.text1.text2.text3.extension"
Please, somebody help me !!!!
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
Hi ozzii,
you could catch this with regular expression:
Find all till the second last dot ==> (.+)\..+\.ext
So add an RegEx Rule
Expression: (.+)\..+
Replace: $1
[x] Skip Extension
This means
. ==> an dot find one char, no matter which
+ ==> find one or as many (greedy) of the same kind as the char before (any char in our case)
() ==> group this to refer back to this find later
\. ==> escaped dot, to find an dot by it self (and not "any char" as above)
. ==> an dot find one char, no matter which
+ ==> find one or as many of the same kind as the char before (any char in our case)
$1 ==> replace whit them found in expression group one
==> we didn't replace the rest..... so this is deleted
Note:
Greedy means "find/catch as many as you can" .... till the last dot in our case.
Try (.+?)\..+ where the ?-sign means "be non-greedy" and you will find all till the first found dot only.
HTH?
Stefan
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Thanks Stefan.
I will test it this afternoon. So I will tell then if all is OK
Thanks.
P.S: I will love to know to use (a little more) RegEx
EDIT:
It's working !!! Thanks a lot
Last edited by ozzii (2007-12-06 07:42)
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
One more question (for Stefan maybe).
How I can do to delete all the end of the name after the latest digit.
For example I can have:
text.100.text2.text3.text4.extension
text.text2.100.text3.text4.extension
text.100.101.text3.text4.extension
For result I will have:
text.100.extension
text.text2.100.extension
text.100.101.extension
Thanks in advance.
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
You are welcome. Great it works.
How I can do to delete all the end of the name after the latest digit.
You have to find someone common in the file names.
For example I can have:
text.100.text2.text3.text4.extension
text.text2.100.text3.text4.extension
text.100.101.text3.text4.extension
Here you want to find an digit.
Then split your file name into parts:
ALL - Digit - Remnant.ext
To find any char use the RegEx . (an dot)
To find all use the RegEx .+
To find one digit use \d
To find one or more digits use \d+
To back referencing later to this find you have to group the search by ()
To find all use the RegEx (.+)
To find one or more digits use (\d+)
Later you are able to get what your RegEx have found back by using an $1 for the first group, an $2 for the second,...
So try
Expression: (.+)(\d+)
Replace: $1$2
-----------------
This didn't works ... you have to catch the hole file name:
To find the remnant use .+ again
So try
Expression: (.+)(\d+).+
Replace: $1$2
(since we didn't need the remnant after the digits later... we don't need to group this)
-----------------
This didn't works ... the first .+ is to greedy. Use an ?-sign to be non-greedy
So try
Expression: (.+?)(\d+).+
Replace: $1$2
-----------------
For result I will have:
text.100.extension
text.text2.100.extension
text.100.101.extensionThanks in advance.
I have no time right now to test this much, but i think this should work.
CY
Stefan
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
YES !!!!!
This is it.
I was trying when you post your answer.
THANKS !!!! This is a really big help (for me at least)
PS: With your explanation, I begin to understand a little more RegEx.
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
Good man, Stefan! I appreciate your help with answering questions on forums!
Ozzi, just wanted to recommend a good place to learn RegEx: http://www.regular-expressions.info/
Offline
Stefan (or someone else) , one more question.
When I have a filename (without the extension) who ended with a digit, last digit is deleted.
I try but with no success; is there a way to not lose the latest digit in this case?
Thanks again.
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
Can you post the exact RegEx expressions that you are using?
And few sample filenames, which do work, and which don't.
Offline
Here it is
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline