#1 : 31/03-19 03:09 jchong
Posts: 7
|
Hello,
I'd like to move the last few characters of a file name to the front. Examples: my cool file name my cool cool file name my cool cool cool file name In all 3 examples above, I want to move "name" to the front, so it becomes: name my cool file name my cool cool file name my cool cool cool file In other words, to move the last 4 characters of the file name to the front. There is no fixed pattern or length in the file name. Would appreciate some help on how to do this. Thanks! |
#2 : 31/03-19 04:31 David Lee
Posts: 1125
|
To do exactly what you ask - ie move the last 4 characters plus a space to the beginning of the name - use the Replace method with a Regular Expression:
Replace: (.*)(.{4}) with: \2 \1 However this will leave a space at the end of the filename - to remove this use: Replace: (.*) (.{4}) with: \2 \1 A more general solution that will move all characters following the final space (ie the last word of any length) to the beginning is simply: Replace: (.*) (.*) with: \2 \1 |
#3 : 31/03-19 07:51 jchong
Posts: 7
|
Thanks for the help! I will try that out.
|