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)

(1/3) > >>

tomos:
I have a list of names - they are actually file names but they arent files

The format of the names is below - where    X or Z are letters or numbers or underscores or '-'    and spaces are spaces.

XXXXXXX XXXXXXXX ZZZZZZZZZ
or
XXXXXXX ZZZZZZZZ

I want to be able to take the last part of the name (ZZZZZZ) and put it in front so I would end up with

ZZZZZZZZZ XXXXXXX XXXXXXXX
or
ZZZZZZZZ XXXXXXX

Basically I want to be able to sort the list via the ZZZZZZZZ part of the name


Maybe this should be in new requests (?) or maybe there is something out there that does this already ?
I dont have Excel but do have Softmaker Office - dont know if it's possible via that...

TIA :) Tom

AndyM:
I dont have Excel but do have Softmaker Office - dont know if it's possible via that...
-tomos (January 08, 2010, 02:42 PM)
--- End quote ---
probably is possible

is the ZZZZ... always the same number of digits and always at the end?  
if not, does the ZZZZ... always begin just after the rightmost space?

if either of these is so, in a column adjacent to your list have a formula that extracts the ZZZZ...(see string formula help), or enough of it to produce a unique list, and then sort the list based on that column.

If you have to have the names actually renamed (just sorting isn't sufficient), you can continue the exercise to construct a string ordered the way you want, and then copy just values from that column (not formulas) to another column to get the list of names.

Alternatively if you have Word, you could do a Search and Replace to move the ZZZZ... to the front of each name.  Any program with a sophisticated enough Search & Replace could be used.

Or someone here can whip up a quick script (which I will keep for future reference!)

f0dder:
sounds like a pretty simple regex job that any decent text editor should be able to handle :)

snail02:
There is a very easy way to do this.
1. First save all the names on a notepad file.
2. Open a new document in Microsoft Excel (or any other spreadsheet software).
3. Select Import "data", and import the notepad file.
4. You can then configure how the data should be imported into the worksheet. If you choose by space or tab, then it will put the words of each line in separate columns.
5. Simply cut the last column and bring it to the front.
6. Now select the entire file list and press ctrl+c. Paste it into a new notepad document.
7. You might notice large gaps between the words. Copy the large gap. Click ctrl+h. Paste it in, and replace with regular one-letter width space.

Hope that works.

AbteriX:
The format of the names is below - where    X or Z are letters or numbers or underscores or '-'    and spaces are spaces.

XXXXXXX XXXXXXXX ZZZZZZZZZ
or
XXXXXXX ZZZZZZZZ

I want to be able to take the last part of the name (ZZZZZZ) and put it in front so I would end up with

ZZZZZZZZZ XXXXXXX XXXXXXXX
or
ZZZZZZZZ XXXXXXX-tomos (January 08, 2010, 02:42 PM)
--- End quote ---

Hy Tom,

any editor with search&replace with reg ex mode can do this.


FROM:
XXXXXXX XXXXXXXX ZZZZZZZZZ
XXXXXXX ZZZZZZZZ
RegEx: find all greedy till last space, then find the rest
RegEx: ^(.+) (.+)$
Explanation:
^ => match start of string
() => group what is found for later back referencing
.  => find one any sign
+ => find (at least)one or (as many as)more from the term just typed before, one of any sign, in our case. But only till the next term is found.
$ => end of string

TO:
ZZZZZZZZZ XXXXXXX XXXXXXXX
ZZZZZZZZ XXXXXXX
Replace: all from group two, then an space, then all from group one
Replace: \2 \1     or $2 $1, belongs what reg ex engine/style is used


So:
open Search&Replace in your favorite text editor or Office
Find: ^(.+) (.+)$
Repl: $2 $1
[X] RegEx


Depending of how your string looks in real, it could be that this RegEx has to be fine tuned. PM me if you like.

HTH?


CU

Navigation

[0] Message Index

[#] Next page

Go to full version