#1 : 21/07-20 23:42 js
Posts: 1
|
Hello, I'm a beginner with the program, I've read that knowing regex can make the use of the program more powerful. However so far I got overwhelmed by all the info about regex and could not find any clue to perform my renaming, could you please give me a hand:
This is an example of the pattern of files I'm working with: #{Tuesday} - 18.01.03 - morning ~36min57sec~.txt This is what I want to do or rename in batch: #{Tuesday} - [Morning] - 18.01.03~36min57sec~.txt |
#2 : 22/07-20 12:06 David Lee
Posts: 1125
|
If you follow the basic introduction to Regular Expressions in the User Guide (www.advancedrenamer.com/user_guide/regular_expresions) then you can come up with the following Replace method...
Replace: (.*- )([\.\d]*) - ([^ ]*) With: \1[\3] - \2 which will return: "#{Tuesday} - [morning] - 18.01.03 ~36min57sec~.txt" "(.*- )" matches any string of characters ending with "-"+space and saves in variable "\1" "([\.\d]*)" matches a string containing only decimal digits or "." and saves in variable "\2" " - " just matches the characters but does not save the string "([^ ]*)" matches a string of any characters up to but not including the next space and saves in variable \3 All matched characters are removed and the replacement string "\1[\3] - \2" replaces the saved variables plus " - " in the desired order. The User Guide describes only very basic Regular Expression syntax and metacharacters - much more information is available if you "Google" online. "\in" will return the contents of variable number "n", with the first character uppercase and the remainder lowercase. "\K" will remove all previously matched characters from the final match, so that they will not be deleted. So an improved Replace method is... Replace: ".*?- \K([\.\d]*) - ([^ ]*)" With: "[\i2] - \1" which will return "#{Tuesday} - [Morning] - 18.01.03 ~36min57sec~.txt" as required. I hope that the explanation will help you to get to grips with RegEx. |