Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to copy a range of lines  (Read 11484 times)

0 Members and 1 Guest are viewing this topic.

bobk544

    Topic Starter


    Rookie

    Re: How to copy a range of lines
    « Reply #15 on: March 04, 2013, 11:34:39 AM »
    ok yes i can run that from the command line, so i'm going to look into this approach now and thanks very  much for  you help as this seems like a tool i should learn! have a good one and thanks agaiin!

    bobk544

      Topic Starter


      Rookie

      Re: How to copy a range of lines
      « Reply #16 on: March 04, 2013, 11:37:44 AM »
      great thanks very much! :)

      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: How to copy a range of lines
      « Reply #17 on: March 04, 2013, 11:51:56 AM »
      While you two were chatting I came up with this modification of some code I found.
      If your system has associations for .vbs files then it will run on just clicking the file - if it is named split.vbs for example.

      It splits at byte boundaries and not line boundaries, and ignores CR/LF line endings.  I'm not sure if that's what you want.

      Code: [Select]
      'infile and outfile must point to different files.

        Const ForReading = 1, ForWriting = 2

        numchrs = 100000      '<= number of characters in each file
        infile = "list.txt"   '<= Set input file here
        outfile = "out-"      '<= Set output file here without extension

        Set fso = CreateObject("Scripting.FileSystemObject")
        remaining = fso.GetFile(infile).Size
        Set f1 = fso.OpenTextFile(infile, ForReading)
        c = 1000000

        Do While remaining > 0

         c = c + 1
         out = outfile & right(c,6) & ".txt"
         Set f2 = fso.OpenTextFile(out, ForWriting, True)

         If remaining > numchrs Then
           remaining = remaining - numchrs
           text = f1.Read(numchrs)
           f2.Write text
           f2.Close
         Else
           text = f1.Read(remaining)
           f2.Write text
           f2.Close
           remaining = 0
         End If
        Loop

        f1.Close
        f2.Close
        Wscript.Echo "done"

      bobk544

        Topic Starter


        Rookie

        Re: How to copy a range of lines
        « Reply #18 on: March 04, 2013, 11:57:39 AM »
        wow great thanks Foxidrive, so i would create a ".bat" file and put that code into the ".bat" file and run that from the command line then? ;D

        foxidrive



          Specialist
        • Thanked: 268
        • Experience: Experienced
        • OS: Windows 8
        Re: How to copy a range of lines
        « Reply #19 on: March 04, 2013, 11:59:42 AM »
        If you called the code 'split.vbs" and put it the same folder as the batch file below, and the source text file, then it should work. 
        Adjust the filename in the script for the source text file.


        Code: [Select]
        @echo off
        cscript /nologo "split.vbs"

        bobk544

          Topic Starter


          Rookie

          Re: How to copy a range of lines
          « Reply #20 on: March 04, 2013, 12:04:32 PM »
          ok great will do and thanks again and Salmon!

          bobk544

            Topic Starter


            Rookie

            Re: How to copy a range of lines
            « Reply #21 on: March 04, 2013, 12:16:36 PM »
            ok that worked great thanks very much foxidrive, i just need to tune it based on the character count, but that's exactly what i was looking for and thanks also Salmon, for helping me with this as well! so thanks to you both as i now am very intersted in these VBScript capabilities!

            bobk544

              Topic Starter


              Rookie

              Re: How to copy a range of lines
              « Reply #22 on: March 04, 2013, 12:25:09 PM »
              thanks again Foxidrive & Salmon, i've heard about VBScript for years but never had a need to use it, so thanks again all for you help all, it always  amazes me that folks like you'all are willing to help others like you do, so hats off to you two, you deserve the best!

              Salmon Trout

              • Guest
              Re: How to copy a range of lines
              « Reply #23 on: March 04, 2013, 12:25:16 PM »
              That's good, it means I can go off and watch the TV now. I shall not bother finishing my script. Glad you are all fixed up, bobk544.


              Salmon Trout

              • Guest
              Re: How to copy a range of lines
              « Reply #24 on: March 04, 2013, 01:42:17 PM »
              Well, just for my own pleasure I completed a script.

              bobk544

                Topic Starter


                Rookie

                Re: How to copy a range of lines
                « Reply #25 on: March 04, 2013, 01:59:27 PM »
                Ok that's great Salmon and fyi i think i just reached the outer stratosphere of a word document after tweaking the byte size and so for doc1 i've got: 30,238 pages and 15 million words!  wow :o
                thanks again all! ;D

                Salmon Trout

                • Guest
                Re: How to copy a range of lines
                « Reply #26 on: March 04, 2013, 02:01:30 PM »
                Why are you doing this?

                bobk544

                  Topic Starter


                  Rookie

                  Re: How to copy a range of lines
                  « Reply #27 on: March 04, 2013, 02:12:19 PM »
                  i'm using MS Word as a document cross reference for software systems and i use another Word document to index all of the items in the system and i used to build everything on UNIX, but now i'm building pieces on Windows and actually i've written some VBA routines, but i've never written any VBScript only ".bat" type code, but now i'm really going to look into VBScript seeing how great it is and it's pretty fast! but Salmon, if you use Word alot i have a VBA routine that i tweaked from some code that Peter Epstein wrote, aka MacroPod and it will hyperlink selected text in a Word document and i use this to create documenation for sofware systems ect, here's a link to that routine  if you ever want to use it: http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/77096ef3-3f15-48b7-b32c-091ebff1c491
                  oh and also i'm now doing alot of XML processing and word itself is XML and therefore an interesting app in itself!

                  bobk544

                    Topic Starter


                    Rookie

                    Re: How to copy a range of lines
                    « Reply #28 on: March 04, 2013, 02:24:35 PM »
                     Here's a view of the index doc and if i highlight a range and select key a VBA routine it will set the hyperlink to a particular program and line on the a program, see the 2nd view below for the program view:
                    allFldsDC.doc @lb <allPgms> <allFlds> <allCF> <allClass> <allCFMSD> <allFiles> <apnd> <req> <C:\_XREF_CNTL\renderingenginesource> <C:\_XREF_BKP\renderingenginesource> <renderingenginesource> @le
                    .1 857 :this:        @b  1h1 1h6 1h8 1h10 1h11 1h12 1h13 1h14 1h15 1h16 1h17 1h18 1h19 1h20 1h21 1h22 1h23 1h26 1h27 1h28 1h30 1h32 1h34 1h35 1h37 1h38 1h39 1h41 1h42 1h43 1h44 1h45 1h46 1h47 1h48 1h70 1h71 1h75 1h76 1h82 1h83 1h84 1h85 1h87 1h88 1h89 1h90 1h91 1h92 1h93 1h94 1h95 1h96 1h100 1h101 1h102 1h111 1h112 1h113 1h114 1h115 1h117 1h118 1h119 1h120 1h121 1h122 1h123 1h124 1h127 1h128 1h129 1h130 1h133 1h134 1h135 1h136 1h137 1h140 1h142 1h143 1h144 1h145 1h146 1h147 1h148 1h149 1h151 1h152 1h153 1h154 1h155 1h156 1h157 1h158 1h159 1h162 1h163 1h164 1h165 1h166 1h167 1h168 1h169 1h170 1h171 1h172 1h173 1h175 1h176 1h177 1h178 1h180 1h181 1h182 1h183 1h184 1h185 1h186 1h187 1h188 1h189 1h190 1h191 1h192 1h195 1h196 1h197 1h199 1h200 1h201 1h202 1h204 1h205 1h206 1h207 1h214 1h215 1h217 1h218 1h219 1h220 1h224 1h226 1h227 1h229 1h230 1h234 1h236 1h237 1h238 1h239 1h240 1h241 1h242 1h243 1h244 1h245 1h246 1h247 1h250 1h251 1h255 1h256 1h258 1h261 1h265 1h273 1h277 1h278 1h281 1h283 1h284 1h285 1h289 1h291 1h292 1h293 1h294 1h296 1h297 1h298 1h299 1h300 1h301 1h302 1h303 1h304 1h305 1h306 1h308 1h309 1h310 1h311 1h312 1h314 1h315 1h317 1h318 1h319 1h321 1h322 1h323 1h324 1h325 1h327 1h329 1h330 1h331 1h332 1h333 1h335 1h338 1h340 1h341 1h342 1h343 1h349 1h350 1h353 1h354 1h355 1h356 1h357 1h358 1h359 1h360 1h361 1h362 1h363 1h364 1h365 1h366 1h367 1h368 1h369 1h370 1h372 1h373 1h374 1h375 1h376 1h377 1h378 1h379 1h380 1h381 1h382 1h386 1h388 1h389 1h390 1h391 1h392 1h393 1h394 1h395 1h396 1h397 1h398 1h401 1h402 1h405 1h406 1h408 1h409 1h410 1h412 1h413 1h414 1h415 1h416 1h418 1h420 1h421 1h422 1h423 1h424 1h426 1h427 1h430 1h432 1h433 1h434 1h436 1h437 1h439 1h443 1h445 1h446 1h447 1h452 1h459 1h461 1h462 1h463 1h464 1h465 1h466 1h468 1h469 1h470 1h471 1h472 1h473 1h474 1h475 1h476 1h477 1h478 1h479 1h480 1h481 1h482 1h483 1h484 1h485 1h486 1h487 1h488 1h489 1h490 1h491 1h492 1h493 1h494 1h495 1h496 1h497 1h498 1h499 1h500 1h501 1h502 1h503 1h504 1h506 1h507 1h508 1h509 1h510 1h511 1h512 1h513 1h514 1h515 1h516 1h517 1h518 1h519 1h520 1h521 1h522 1h523 1h524 1h525 1h526 1h527 1h528 1h529 1h530 1h531 1h532 1h533 1h534 1h536 1h537 1h538 1h539 1h540 1h543 1h544 1h545 1h546 1h547 1h548 1h549 1h550 1h551 1h552 1h553 1h554 1h555 1h557 1h558 1h559 1h560 1h561 1h564 1h565 1h566 1h567 1h568 1h571 1h572 1h573 1h574 1h575 1h576 @e  :159
                    .2 857 :sec:        @b  1h1 1h6 1h35 1h37 1h50 1h51 1h52 1h53 1h58 1h59 1h60 1h61 1h62 1h63 1h64 1h65 1h66 1h67 1h68 1h69 1h70 1h71 1h72 1h73 1h74 1h82 1h83 1h84 1h85 1h91 1h92 1h100 1h101 1h102 1h103 1h104 1h105 1h106 1h107 1h111 1h112 1h113 1h114 1h118 1h201 1h248 1h412 1h427 1h439 1h443 1h445 1h455 1h462 1h508 1h528 1h533 1h581 1h593 1h649 1h650 1h651 1h652 1h663 1h709 1h748 1h763 1h765 1h766 1h767 1h768 1h773 1h774 1h775 1h776 1h777 1h778 1h779 1h780 1h781 1h782 1h783 1h784 1h785 1h786 1h787 1h788 1h789 1h797 1h798 1h799 1h800 1h806 1h807 1h815 1h816 1h817 1h818 1h819 1h820 1h821 1h822 1h826 1h827 1h828 1h829 1h833 @e  :159
                    .3 857 :rendering:        @b  1h1 1h6 1h23 1h35 1h91 1h92 1h97 1h98 1h99 1h111 1h112 1h113 1h114 1h118 1h129 1h165 1h192 1h245 1h280 1h281 1h282 1h288 1h439 1h443 1h445 1h533 1h762 1h806 1h807 1h812 1h813 1h814 1h826 1h827 1h828 1h829 1h833 1h844 @e  :159
                    .4 857 :engine:        @b  1h1 1h35 1h37 1h46 1h91 1h92 1h97 1h98 1h99 1h105 1h106 1h107 1h129 1h163 1h202 1h233 1h234 1h236 1h241 1h246 1h248 1h273 1h275 1h292 1h294 1h295 1h298 1h305 1h311 1h312 1h313 1h314 1h315 1h317 1h319 1h321 1h322 1h323 1h324 1h325 1h330 1h339 1h340 1h342 1h344 1h345 1h348 1h350 1h351 1h353 1h360 1h363 1h371 1h395 1h401 1h402 1h405 1h439 1h443 1h445 1h470 1h471 1h472 1h500 1h650 1h652 1h688 1h754 1h763 1h806 1h807 1h812 1h813 1h814 1h820 1h821 1h822 1h844 @e  :159
                    .5 857 :source:        @b  1h1 1h42 1h111 1h112 1h113 1h114 1h115 1h117 1h136 1h137 1h168 1h188 1h190 1h197 1h201 1h215 1h227 1h236 1h237 1h241 1h244 1h258 1h273 1h292 1h293 1h298 1h299 1h302 1h303 1h311 1h312 1h318 1h319 1h332 1h337 1h342 1h349 1h382 1h384 1h386 1h408 1h412 1h416 1h418 1h445 1h452 1h475 1h477 1h478 1h480 1h481 1h500 1h508 1h519 1h528 1h531 1h533 1h646 1h650 1h659 1h663 1h684 1h723 1h725 1h742 1h744 1h747 1h752 1h754 1h760 1h762 1h826 1h827 1h828 1h829 1h830 1h832 1h850 1h851 @e  :159
                    .6 857 :for:        @b  1h1 1h2 1h6 1h8 1h11 1h13 1h14 1h15 1h19 1h21 1h23 1h24 1h25 1h27 1h28 1h30 1h32 1h34 1h35 1h37 1h38 1h41 1h42 1h43 1h46 1h47 1h48 1h70 1h71 1h75 1h76 1h82 1h83 1h84 1h85 1h87 1h88 1h89 1h90 1h91 1h92 1h93 1h94 1h95 1h96 1h97 1h98 1h99 1h100 1h101 1h102 1h103 1h104 1h105 1h106 1h107 1h111 1h112 1h113 1h114 1h115 1h117 1h118 1h126 1h128 1h129 1h130 1h134 1h136 1h137 1h140 1h142 1h143 1h145 1h147 1h149 1h151 1h153 1h154 1h156 1h157 1h158 1h159 1h163 1h164 1h165 1h166 1h167 1h168 1h169 1h170 1h172 1h173 1h174 1h175 1h176 1h177 1h178 1h181 1h182 1h184 1h186 1h187 1h191 1h192 1h193 1h197 1h199 1h200 1h201 1h202 1h204 1h205 1h206 1h207 1h213 1h214 1h216 1h219 1h220 1h224 1h226 1h227 1h236 1h237 1h238 1h239 1h242 1h243 1h244 1h245 1h246 1h247 1h249 1h251 1h252 1h253 1h255 1h256 1h258 1h261 1h265 1h268 1h271 1h273 1h274 1h275 1h276 1h277 1h278 1h283 1h284 1h285 1h286 1h287 1h289 1h291 1h292 1h294 1h296 1h297 1h298 1h299 1h300 1h301 1h303 1h304 1h305 1h306 1h308 1h309 1h310 1h311 1h314 1h315 1h317 1h318 1h319 1h321 1h322 1h323 1h326 1h327 1h328 1h329 1h330 1h331 1h332 1h333 1h334 1h335 1h336 1h337 1h338 1h340 1h341 1h342 1h344 1h346 1h347 1h348 1h349 1h350 1h352 1h353 1h358 1h359 1h360 1h361 1h362 1h363 1h365 1h369 1h370 1h374 1h375 1h376 1h377 1h378 1h382 1h383 1h384 1h385 1h386 1h387 1h388 1h389 1h392 1h393 1h394 1h395 1h396 1h397 1h398 1h401 1h402 1h405 1h406 1h410 1h412 1h413 1h414 1h415 1h418 1h419 1h420 1h421 1h422 1h423 1h424 1h430 1h431 1h432 1h433 1h434 1h435 1h436 1h437 1h439 1h443 1h445 1h455 1h459 1h461 1h462 1h463 1h464 1h465 1h466 1h468 1h469 1h470 1h471 1h472 1h473 1h474 1h475 1h476 1h477 1h478 1h479 1h480 1h481 1h482 1h483 1h484 1h485 1h486 1h487 1h488 1h489 1h490 1h491 1h492 1h493 1h494 1h495 1h496 1h497 1h498 1h499 1h500 1h501 1h502 1h503 1h504 1h505 1h506 1h508 1h509 1h510 1h511 1h512 1h513 1h514 1h515 1h516 1h517 1h518 1h519 1h520 1h521 1h522 1h523 1h524 1h525 1h526 1h527 1h528 1h529 1h530 1h531 1h532 1h533 1h534 1h537 1h538 1h539 1h540 1h543 1h544 1h545 1h546 1h547 1h548 1h549 1h550 1h551 1h552 1h553 1h554 1h555 1h557 1h558 1h559 1h560 1h561 1h564 1h565 1h566 1h567 1h568 1h571 1h572 1h573 1h574 1h575 1h576 1h577 1h578 1h579 1h580 1h581 1h582 1h583 1h584 1h585 1h586 1h587 1h588 1h589 1h590 1h591 1h592 1h593 1h594 1h595 1h596 1h597 1h598 1h599 1h600 1h601 1h602 1h603 1h604 1h605 1h606 1h607 @e  :159
                    .7 857 :version:        @b  1h1 1h2 1h5 1h25 1h31 1h35 1h40 1h41 1h42 1h52 1h53 1h56 1h57 1h59 1h60 1h63 1h64 1h65 1h70 1h71 1h72 1h73 1h74 1h75 1h76 1h77 1h78 1h79 1h80 1h81 1h82 1h83 1h84 1h85 1h86 1h87 1h88 1h89 1h90 1h91 1h92 1h93 1h94 1h95 1h96 1h97 1h98 1h99 1h100 1h101 1h102 1h103 1h104 1h105 1h106 1h107 1h108 1h109 1h110 1h111 1h112 1h113 1h114 1h115 1h116 1h117 1h118 1h119 1h120 1h121 1h122 1h123 1h124 1h125 1h126 1h127 1h128 1h129 1h130 1h133 1h134 1h135 1h136 1h137 1h139 1h140 1h158 1h163 1h190 1h197 1h208 1h224

                    Progam document:
                    C:\_XREF_ALL\renderingenginesource\Common\Utilities\AucentCustomEventLogSource.cs.doc @lb <allPgms> <allFlds> <allCF> <allClass> <allCFMSD> <allFiles> <apnd> <req> <C:\_XREF_CNTL\renderingenginesource> <C:\_XREF_BKP\renderingenginesource> <renderingenginesource> @le
                    C:\_XREF_ALL\renderingenginesourceR1\Common\Utilities\AucentCustomEventLogSource.cs.doc
                    C:\_XREF_BKP\renderingenginesource\Common\Utilities\AucentCustomEventLogSource.cs.doc
                    .1 646 // ===========================================================================================================
                    .2 646 //  Common Public Attribution License Version 1.0. @b <comn>  36c492 @e
                    .3 646 //
                    .4 646 //  The contents of this file are subject to the Common Public Attribution License Version 1.0 (the �License�);  @b <thee>  63c353 <comn>  36c492 @e
                    .5 646 //  you may not use this file except in compliance with the License. You may obtain a copy of the License at @b <with>  57c463 57c469 64c469 324f258 <thee>  63c353 @e
                    .6 646 //  http://www.rivetsoftware.com/content/index.cfm?fuseaction=showContent&contentID=212&navID=180.
                    .7 646 //
                    .8 646 //  The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to  @b <thee>  63c353 <basd>  439f315 <*censored*>  110c314 120c314 130c314 55c482 <andd>  5c405 319f258 567f500 @e
                    .9 646 //  cover use of software over a computer network and provide for limited attribution for the Original Developer.  @b <andd>  5c405 319f258 567f500 <forr>  34c35 11c244 13c245 2c249 2c252 2c253 2c273 2c274 2c276 7c338 7c346 7c347 105c445 145c445 44c469 46c478 40c500 32m283 255m283 322m283 385m283 <thee>  63c353 @e
                    .10 646 //  In addition, Exhibit A has been modified to be consistent with Exhibit B. @b <with>  57c463 57c469 64c469 324f258 @e
                    .11 646 //
                    .12 646 //  Software distributed under the License is distributed on an �AS IS� basis, WITHOUT WARRANTY OF ANY KIND,  @b <thee>  63c353 @e
                    .13 646 //  either express or implied. See the License for the specific language governing rights and limitations  @b <thee>  63c353 <forr>  34c35 11c244 13c245 2c249 2c252 2c253 2c273 2c274 2c276 7c338 7c346 7c347 105c445 145c445 44c469 46c478 40c500 32m283 255m283 322m283 385m283 <andd>  5c405 319f258 567f500 @e
                    .14 646 //  under the License. @b <thee>  63c353 @e
                    .15 646 //
                    .16 646 //  The Original Code is Rivet Dragon Tag XBRL Enabler. @b <thee>  63c353 @e
                    .17 646 //
                    .18 646 //  The Initial Developer of the Original Code is Rivet Software, Inc.. All portions of the code written by  @b <thee>  63c353 @e
                    .19 646 //  Rivet Software, Inc. are Copyright (c) 2004-2008. All Rights Reserved.
                    .20 646 //
                    .21 646 //  Contributor: Rivet Software, Inc..
                    .22 646 // ===========================================================================================================
                    .23 646 using System;
                    .24 646 using System.Diagnostics;
                    .25 646 using System.Collections;
                    .26 646 using System.Collections.Generic;
                    .27 646 using Aucent.MAX.AXE.Common.Exceptions; @b <comn>  36c492 @e
                    .28 646
                    .29 646 namespace Aucent.MAX.AXE.Common.Utilities @b <comn>  36c492 @e
                    .30 646 {
                    .31 646    /// <summary>



                    But the big document that we just split apart is the all document where i concatenate all of the documents into 1 big document and in this case i had to split this big document into several smaller documents and then link the index docs.

                    But Word is a pretty amazing tool and the hyperlinks work great, so i can literally hyperlink thru a system in a few minutes, no matter how big it is!

                    foxidrive



                      Specialist
                    • Thanked: 268
                    • Experience: Experienced
                    • OS: Windows 8
                    Re: How to copy a range of lines
                    « Reply #29 on: March 05, 2013, 03:33:21 AM »
                    It splits at byte boundaries and not line boundaries, and ignores CR/LF line endings.  I'm not sure if that's what you want.

                    FWIW it doesn't ignore CR/LF - it can also be used on binary files.