Tbird wrote:I would like to be able to rename file names as per the following:
1) word1 word2 - word3, word4.ext -> word4 word3 - word1 word2.ext
2) word1 word2 word3 - word4, word5.ext -> word5 word4 - word1 word2 word3.ext
3) word1 - word2, word3 & word4 word5.ext -> word3 word2 & word4 word5 - word1.ext
As there are thousands of files is there a way for the expression to take all the variables into consideration and rename them all in one sweep?
Or will the files need to be segregated into each category (1, 2 or 3) first them batch rename?
Thank for your help!
Three categories , yes.
Let's try first category:
All those "words" didn't contain any space? OK, that's fine.
So you can use regular expressions to search for "anything" till an blank, or an coma or an & or an dash.
Split your string into parts like:
PART1: word1
PART2 word2
-
PART3 word3
,
PART4 word4
To match one-or-more of any sign ===> use RegEx: (.+)
That was is matched is "stored" inside the ( ) parenthesis
and you can reuse this by using "\1" etc.
SO for 1.)
FROM:
word1 word2 - word3, word4
TO:
word4 word3 - word1 word2
DO:
RegEx(1)
Search: (.+?) (.+?) - (.+?) (.+)
Repla: \4 \3 - \1 \2You may read the other threads too, there you will find maybe more explanations.
General notes/ DisclaimerHope this helps ?
If yes, please help two others too. And consider an donation to the tools autor.
Please note:
Always don't trust me! Test with test files first!
* Usually i do a few tests on this issue only!
* So please test my solution with some test files first before you destroy your data.
* Select one or more files in the Name column to watch how the New Name will be.
RegEx is an pattern matching solution, so all your files have to fit into the same pattern.
If they not, you have to separate them and run some more actions against them.
To find your own solution you have to virtual (in mind) split your file names/strings into parts
following the rules of the regular expression syntax, see the help file coming with your application.
(Please note that there are several flavors of RE engines and also different implementations into apps
and even different ways of doing or thinking, so your expiriences may differ from my explanation)
Once you have split your string into parts you can decide which to use into replacement by grouping the pattern
into (...) parenthesis to which you can refer by using "\1" or "$1" signs later, or which to drop and which to modify.
My solution depends on the quality of your examples.
* It's always an good idea to provide all possibilities of file name pattern in question.
* That would give the supporter an change to do it right
* If your real file names doesn't fit into your example pattern my solution may fail.
 So provide us always real live examples of your file names. Or we have to extend the talk over several days.
 (Of course you can sophisticate your secrets)
* Don't use this ' ' or " " -quotes from my explanation. They are only for clarification.
* '?' means non-greedy: stop at first match, instead of last possible.
* This (...) parenthesis are used to "group" what is found by this RegEx inside the ( )'s
to reuse this capture later as replacement by using \1 .
* Instead of ~ -signs, if used in my explanations, type an space/blank.
More Help
* online tester:
- http://rereplace.com/
- http://www.regextester.com/
- http://www.regexlib.com/RETester.aspx
* online help:
- www.regular-expressions.info
- www.regexlib.com/
- www.regexlib.com/CheatSheet.aspx
See this both oldest threads in the "Regular Expressions" forum for an RegEx syntax overview:
=> Getting Started: http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=3&t=5
=> Go ahead: http://www.bulkrenameutility.co.uk/forum/viewtopic.php?f=3&t=27
There you will find more examples and tips as you may find in other threads in the "Regular Expressions" sub-forum.