Need to save each line as a new file using part of the line

Need to save each line as a new file using part of the line

preichar

    Jun 21, 2005#1

    Need to save each line as a new file using part of the line as the name. See next:

    Here is my current file:
    first_name=&last_name=&city=&rowBegins=00001&reference=/memberdirectory/results.cfm
    first_name=&last_name=&city=&rowBegins=00026&reference=/memberdirectory/results.cfm
    first_name=&last_name=&city=&rowBegins=00051&reference=/memberdirectory/results.cfm
    first_name=&last_name=&city=&rowBegins=00076&reference=/memberdirectory/results.cfm
    first_name=&last_name=&city=&rowBegins=00101&reference=/memberdirectory/results.cfm



    I want to save the first line into a file all by itself and name it 00001.txt
    Then the next line should be in a file all by itself and named 0026.txt and so on, there are 1510 line in theis file, so I am looking for 1510 .txt files when I am done.


    All of my attempts at a macro have produced nothing short of a complete mess! :)

    Thanks for some help!
    Jason.

    6,683583
    Grand MasterGrand Master
    6,683583

      Re: Need to save each line as a new file using part of the l

      Jun 22, 2005#2

      That's really tricky, but I found the solution. It cannot be done with a UE macro directly. But the file can be converted by a macro to macro code, which does the job. Here is the macro, which converts your file into macro code.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Bottom
      IfColNum 1
      Else
      "
      "
      EndIf
      Top
      Find RegExp "%^(*Begins=^)^([0-9]+^)^(*^)$"
      Replace All "SelectAll^p"^1^2^3^p"^pSaveAs "^2.txt""
      Top
      "InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      NewFile
      "


      When you run this macro on your file, you will get

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      NewFile
      SelectAll
      "first_name=&last_name=&city=&rowBegins=00001&reference=/memberdirectory/results.cfm
      "
      SaveAs "00001.txt"
      SelectAll
      "first_name=&last_name=&city=&rowBegins=00026&reference=/memberdirectory/results.cfm
      "
      SaveAs "00026.txt"
      SelectAll
      "first_name=&last_name=&city=&rowBegins=00051&reference=/memberdirectory/results.cfm
      "
      SaveAs "00051.txt"
      SelectAll
      "first_name=&last_name=&city=&rowBegins=00076&reference=/memberdirectory/results.cfm
      "
      SaveAs "00076.txt"
      SelectAll
      "first_name=&last_name=&city=&rowBegins=00101&reference=/memberdirectory/results.cfm
      "
      SaveAs "00101.txt"


      Now copy your converted file into the edit macro dialog and run the macro.
      Best regards from an UC/UE/UES for Windows user from Austria

      261
      Basic UserBasic User
      261

        Re: Need to save each line as a new file using part of the l

        Jun 22, 2005#3

        Jasgot,

        I think you can do it this way as well:

        Code: Select all

        InsertMode
        ColumnModeOff
        HexOff
        UnixReOn
        Bottom
        IfColNum 1
        Else
        "
        "
        EndIf
        Top
        Loop 
        IfEof
        ExitLoop
        EndIf
        SelectLine 
        Copy 
        Key HOME
        NewFile
        Paste 
        Top
        Find RegExp "^(.*rowBegins=)(\d+)(.*)$"
        Replace "\1\2\3\n\2.txt"
        StartSelect
        Key HOME
        EndSelect
        Cut 
        Key DEL
        SaveAs "^c"
        CloseFile NoSave
        EndLoop
        
        This uses UNIX RE and assumes the new files go in the same directory as the current file.

        Dave
        ASTTMan
        I'm not a Texan, I just live here.