1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Text renaming?

Discussion in 'BlackHat Lounge' started by hawke, Oct 9, 2009.

  1. hawke

    hawke Power Member

    Joined:
    Nov 14, 2008
    Messages:
    644
    Likes Received:
    533
    Location:
    Ohio
    Let's say I have a list like this
    Code:
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxx.xxxxx
    
    And it needs to look like this
    Code:
    GrpList_0000=alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxx
    GrpList_0001=alt.xxxxxxxx.xxxxxxx.xxxxxx.xxxxxxxx
    
    They need to be in sequential order, is there an automated way of renaming these? As i have nearly 100,000 lines to do this for :(
     
  2. twoj04

    twoj04 Power Member

    Joined:
    Apr 23, 2009
    Messages:
    632
    Likes Received:
    365
    Occupation:
    Self-employed (Hopefully you are also)
    Location:
    115164132199648
    There might be a simpler way to do this, but this is the best way I would do it, and it won't take long.

    Replace all "alt." with GrpList_" then open up excel and start with 0000 in a column, use the fill function to go numerically down until whatever you need (Ex. 1,472). Then you could either copy/paste the column or open up the whole thing in a .csv (placing commas in between by using replace all function again).

    Sorry if this sounds confusing, I had to do quite a bit of this type of stuff when starting off some projects a year or so back.
     
  3. xcubic

    xcubic Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 24, 2008
    Messages:
    440
    Likes Received:
    582
    Location:
    Internet
    Pm me and I'll make you a quick and small tool to do it... ;)
     
  4. bpaw

    bpaw Junior Member

    Joined:
    Aug 9, 2008
    Messages:
    175
    Likes Received:
    48
    Home Page:
    If you have access to a Unix/Linux shell, you can use the following awk command to give you your desired results:

    Code:
    awk 'BEGIN {OFS=""} {printf "%s%04d%s","GrpList_",""NR-1"","="$1"\n"}' filenamehere
    The file "filenamehere" contains:
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxxxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxxxxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxx
    alt.xxxxxxx.xxxxxxx.xxxxxx.xxx.xxxxx