Only possible if "firstname" didn't contain any <space>
Try an regex search&replace:
- Code: Select all
Name:Â 4digityear<space>firstname<space>lastname<space>birthyear
Match: (\d\d\d\d)<space> (.+) <space> (.+) <space> (\d+)
Group: \1 \2 \3 \4
RegEx(1)
Match: (\d\d\d\d) (.+) (.+) (\d+)
Repla: \1 \3 \2 \4
or
Match: (\d\d\d\d) (.+?) (.+) (\d+)
Repla: \1 \3 \2 \4
belfix wrote:Hi
Can this be done please and if, how?
Got a few thousand files that lets say the file name consists of:-
4digityear<space>firstname<space>lastname<space>birthyear
where <space> is actualy a space character and the firstname and lastname fields are variable length.
What I need to do is rename them to a format such that the firstname replaces the
lastname and the lastname replaces the first name. The file extension would remain the same.
Hoping quite simples?
regards
General notes/ DisclaimerHope this helps ?

Please note:
* Test my solution first with some test files before you destroy your data.
* 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.
* 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 or $1.
* Instead of ~ -signs, if used in my explanations, type an space/blank.
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 experiences 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.
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. Read other threads in the "Regular Expressions" sub-forum too.
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