ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

"Renaming" a list of names (not files)

<< < (2/3) > >>

I started reading about regex lately - I didnt get very far so your explanation is very helpful Stefan :Thmbsup:
Will try it out later or tomorrow (only passing through now) & will try snail02's as well

Thanks all  :)

Or, you could just copy paste the strings (names) from Word to an Excel spreadsheet, and if Excel does not automatically set them into columns but just one column, then you could maybe save time and treat each cell as a compound name with
" " (space character) as a delimiter.

Then you could use Excel's string-handling functions.
For example, with a string which has a compound name "Firstname Middlename Lastname" something like:
Search compound name for First name: =LEFT(A2,SEARCH(" ",A2,1)-1)
Search compound name for Last name: =RIGHT(A2,LEN(A2)-SEARCH(" ",A2,1))

If ZZZ is always the last string in the compound name and you want it to become the first string, then this would be a relatively simple exercise to extract and sort out in Excel, and then it would be automated for the next time you needed to do it.

Thanks Iain,
I'm afraid I dont have Excel though (mentioned above)
I do have Softmaker office (Planmaker), I can have a look there with your suggestions but I presume they work different

Snail2, your suggestion doesnt work due to some names having three 'parts', some only two

Re the RegEx - can someone recommend a Text Editor for this ? Textmaker doesnt seem to be able to use the regex.
I have a notepad replacement (Win32Pad) - doesnt seem to be able to handle it either

tomos: try Notepad++ - it's built-in regex engine is relatively weak (because it uses the one from the Scintilla editing component, rather than PCRE/whatever), but should be able to handle a simple regex like this.

Here's some AHK code to do what you want.  Simply copy your text to the clipboard and run this script.  The modified output will be copied back out to your clipboard.  Alternately, this snippet could easily be modified into a hotkey.

--- Code: AutoIt ---Text := Clipboard Block := ""Loop, Parse, Text, `n, `r{    RegExMatch( A_LoopField, "^(.+) (.+)$", SubPat )    Block .= SubPat2 . " " . SubPat1 . "`n"    } Clipboard := Block


[0] Message Index

[#] Next page

[*] Previous page

Go to full version