Command Line Utility to split text file by number of lines

I'm looking for an windows command line utility that can split files
by number of line.  Most of them are by bytes... can anyone
recommend ?  Thanks.
1
dingdongdingding
4/6/2010 2:39:49 AM
windowsxp.general 3897 articles. 1 followers. Follow

8 Replies
9562 Views

Similar Articles

[PageSpeed] 19

You could write your own or try this:

<http://www.gdgsoft.com/gsplit/>

If you tell me what you want to do, I can do it for you and send
you by email.  Send me a sample file and tell me how many lines in
each file and I will do it for you.  Make sure the files are text
files not binary files because lines only apply to text files.

hth


dingdongdingding wrote:
> 
> I'm looking for an windows command line utility that can split files
> by number of line.  Most of them are by bytes... can anyone
> recommend ?  Thanks.

-- 
THE INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND. LD55ZRA DISCLAIMS ALL WARRANTIES, EITHER EXPRESSED OR
IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL LD55ZRA
OR ITS ASSOCIATES BE LIABLE FOR ANY DAMAGES WHATSOEVER
INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF
BUSINESS PROFITS OR SPECIAL DAMAGES,  EVEN IF LD55ZRA OR ITS
ASSOCIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR
LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL
DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright LD55ZRA 2010.
1
LD55ZRA
4/6/2010 3:35:10 AM
"dingdongdingding" <dingdongdingding@yahoo.com> wrote in message 
news:85c44ac3-bb4f-4dbe-a629-c7ea09cd30c0@b33g2000yqc.googlegroups.com...
> I'm looking for an windows command line utility that can split files
> by number of line.  Most of them are by bytes... can anyone
> recommend ?  Thanks.

Your spec is a little vague but perhaps this batch file will ding the way 
you want it to dong:
@echo off
set sName=d:\My Files\My Text File.txt
set iLines=30
echo.
if not exist "%sName%" (
  echo File "%sName%" not found
  goto :eof
)
set Scr="%temp%\TempVBS.vbs"
set VB=echo^>^>%Scr%
cd 1>nul 2>%Scr%
%VB% Set oFSO = CreateObject("Scripting.FileSystemObject")
%VB% Set oFile = oFSO.OpenTextFile("%sName%")
%VB% aFile = Split(oFile.ReadAll, VbCrLf)
%VB% oFile.Close
%VB% Set oOut1 = oFSO.CreateTextFile("%sName%" ^& ".1",True)
%VB% Set oOut2 = oFSO.CreateTextFile("%sName%" ^& ".2",True)
%VB% if %iLines% ^> ubound(aFile) then iLines = UBound(aFile)+1
%VB% For i = 0 To %iLines%-1
%VB%   oOut1.WriteLine aFile(i)
%VB% Next
%VB% oOut1.Close
%VB% If UBound(aFile) ^>= %iLines% Then
%VB%   For i = %iLines% To UBound(aFile)
%VB%     oOut2.WriteLine aFile(i)
%VB%   Next
%VB% End If
%VB% oOut2.Close
cscript //nologo %Scr%
rem del %Scr%
echo Data stored in "%sName%.1" and "%sName%.2" 

1
Pegasus
4/6/2010 9:05:09 AM
On 05 Apr 2010, dingdongdingding <dingdongdingding@yahoo.com> wrote in 
microsoft.public.windowsxp.general:

> I'm looking for an windows command line utility that can split files
> by number of line.  Most of them are by bytes... can anyone
> recommend ?  Thanks.

There are Windows ports of the unix head, tail, and split utilities. 
Some combination of those could probably be scripted to do what you 
want.
1
Nil
4/6/2010 4:31:57 PM
Interesting.  When I tested this, I got 2 files.  1st one with first n
lines.  The 2nd one has the rest of the lines (> n lines insde).

On Apr 6, 5:05=A0pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "dingdongdingding" <dingdongdingd...@yahoo.com> wrote in message
>
> news:85c44ac3-bb4f-4dbe-a629-c7ea09cd30c0@b33g2000yqc.googlegroups.com...
>
> > I'm looking for an windows command line utility that can split files
> > by number of line. =A0Most of them are by bytes... can anyone
> > recommend ? =A0Thanks.
>
> Your spec is a little vague but perhaps this batch file will ding the way
> you want it to dong:
> @echo off
> set sName=3Dd:\My Files\My Text File.txt
> set iLines=3D30
> echo.
> if not exist "%sName%" (
> =A0 echo File "%sName%" not found
> =A0 goto :eof
> )
> set Scr=3D"%temp%\TempVBS.vbs"
> set VB=3Decho^>^>%Scr%
> cd 1>nul 2>%Scr%
> %VB% Set oFSO =3D CreateObject("Scripting.FileSystemObject")
> %VB% Set oFile =3D oFSO.OpenTextFile("%sName%")
> %VB% aFile =3D Split(oFile.ReadAll, VbCrLf)
> %VB% oFile.Close
> %VB% Set oOut1 =3D oFSO.CreateTextFile("%sName%" ^& ".1",True)
> %VB% Set oOut2 =3D oFSO.CreateTextFile("%sName%" ^& ".2",True)
> %VB% if %iLines% ^> ubound(aFile) then iLines =3D UBound(aFile)+1
> %VB% For i =3D 0 To %iLines%-1
> %VB% =A0 oOut1.WriteLine aFile(i)
> %VB% Next
> %VB% oOut1.Close
> %VB% If UBound(aFile) ^>=3D %iLines% Then
> %VB% =A0 For i =3D %iLines% To UBound(aFile)
> %VB% =A0 =A0 oOut2.WriteLine aFile(i)
> %VB% =A0 Next
> %VB% End If
> %VB% oOut2.Close
> cscript //nologo %Scr%
> rem del %Scr%
> echo Data stored in "%sName%.1" and "%sName%.2"

1
dingdongdingding
4/7/2010 12:44:20 AM
Unix has this split command.  Can't find the windows equivalent.

On Apr 7, 12:31=A0am, Nil <redno...@REMOVETHIScomcast.net> wrote:
> On 05 Apr 2010, dingdongdingding <dingdongdingd...@yahoo.com> wrote in
> microsoft.public.windowsxp.general:
>
> > I'm looking for an windows command line utility that can split files
> > by number of line. =A0Most of them are by bytes... can anyone
> > recommend ? =A0Thanks.
>
> There are Windows ports of the unix head, tail, and split utilities.
> Some combination of those could probably be scripted to do what you
> want.

1
dingdongdingding
4/7/2010 12:44:51 AM
This is exactly the way I wrote it. As I said, your spec was somewhat vague 
and allowed several interpretations.

"dingdongdingding" <dingdongdingding@yahoo.com> wrote in message 
news:9cc8f67f-8704-4443-98e5-0001876ba705@z6g2000yqz.googlegroups.com...
> Interesting.  When I tested this, I got 2 files.  1st one with first n
> lines.  The 2nd one has the rest of the lines (> n lines insde).
>
> On Apr 6, 5:05 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
>> "dingdongdingding" <dingdongdingd...@yahoo.com> wrote in message
>>
>> news:85c44ac3-bb4f-4dbe-a629-c7ea09cd30c0@b33g2000yqc.googlegroups.com...
>>
>> > I'm looking for an windows command line utility that can split files
>> > by number of line.  Most of them are by bytes... can anyone
>> > recommend ?  Thanks.
>>
>> Your spec is a little vague but perhaps this batch file will ding the way
>> you want it to dong:
>> @echo off
>> set sName=d:\My Files\My Text File.txt
>> set iLines=30
>> echo.
>> if not exist "%sName%" (
>>   echo File "%sName%" not found
>>   goto :eof
>> )
>> set Scr="%temp%\TempVBS.vbs"
>> set VB=echo^>^>%Scr%
>> cd 1>nul 2>%Scr%
>> %VB% Set oFSO = CreateObject("Scripting.FileSystemObject")
>> %VB% Set oFile = oFSO.OpenTextFile("%sName%")
>> %VB% aFile = Split(oFile.ReadAll, VbCrLf)
>> %VB% oFile.Close
>> %VB% Set oOut1 = oFSO.CreateTextFile("%sName%" ^& ".1",True)
>> %VB% Set oOut2 = oFSO.CreateTextFile("%sName%" ^& ".2",True)
>> %VB% if %iLines% ^> ubound(aFile) then iLines = UBound(aFile)+1
>> %VB% For i = 0 To %iLines%-1
>> %VB%   oOut1.WriteLine aFile(i)
>> %VB% Next
>> %VB% oOut1.Close
>> %VB% If UBound(aFile) ^>= %iLines% Then
>> %VB%   For i = %iLines% To UBound(aFile)
>> %VB%     oOut2.WriteLine aFile(i)
>> %VB%   Next
>> %VB% End If
>> %VB% oOut2.Close
>> cscript //nologo %Scr%
>> rem del %Scr%
>> echo Data stored in "%sName%.1" and "%sName%.2"
> 
1
Pegasus
4/7/2010 6:08:10 AM
On 06 Apr 2010, dingdongdingding <dingdongdingding@yahoo.com> wrote
in microsoft.public.windowsxp.general: 

> Unix has this split command.  Can't find the windows equivalent.

Here's two:

http://openetwork.com/berk.html

http://www.softwareonline.org/winxs42.html

I've seen others. It often comes in a bundle with a bunch of other unix 
utilities.
1
Nil
4/7/2010 3:46:59 PM
Thanks. I think the split from http://openetwork.com/berk.html is good
for me.

Thanks everybody !

On Apr 7, 11:46=A0pm, Nil <redno...@REMOVETHIScomcast.net> wrote:
> On 06 Apr 2010, dingdongdingding <dingdongdingd...@yahoo.com> wrote
> in microsoft.public.windowsxp.general:
>
> > Unix has this split command. =A0Can't find the windows equivalent.
>
> Here's two:
>
> http://openetwork.com/berk.html
>
> http://www.softwareonline.org/winxs42.html
>
> I've seen others. It often comes in a bundle with a bunch of other unix
> utilities.

1
dingdongdingding
4/8/2010 1:23:14 AM
Reply:

Similar Artilces:

Where the cursor starts after clicking no a text box
Hello, I have tried looking through the other threads but have not seen the answer to my question. Hopefully someone can help with this today. I have a simple form I made for a table to collect customer info for a mailing list. This form is used like a kiosk at trade shows. Anyway, when you click on any fields that are numbers such as zip codes or phone numbers, the cursor starts in the text box where you clicked. Is there a way to make the cursor start on the left side no matter where the user clicked? Please help ASAP as I have a show tomorrow and am pulling out my hair trying to fin...

Word art to PDF file
When I use Word Art in a document and save it as a PDF file - the word art is not readable or has a large black shadow behind it. How do I fix this? -- Becky What version Publisher are you using? Are there gradients in your WordArt? This article addresses 2003 but it is true for 2007 as well WordArt gradient fill may print incorrectly in Publisher 2003 http://support.microsoft.com/kb/828829/en-us If you have Publisher 2007 you might try Office's save as PDF. You might get a more satisfactory conversion. It is a free add-in https://www.microsoft.com/downloads/details.aspx?FamilyId=4...

how to remove line numbers in excel
I am fairly new to excel and need to know how to remove the line numbers and the alphabetical cell letters at the top of my page. They appear when I print my report and I have been trying for hours to fix the problem but to no avail. I live in a remote area & don't have any assistance available. Thanks a heap to anyone in advance for your time. -- aquietachiever Hi, In print preview use the Setup button to display the Page Setup dialog. On the Sheet tab is a section Print. make sure 'Row and column headings' is unchecked. Cheers Andy bitty_betsy wrote: > I am fairl...

alignment of big text tools
hi, i want to change the alignment of big text tools from left to right to right to left and the property of aligment doe't exist in Modifer for that tool Pls Help me ASAP thank you in Advance .. Mona I am not sure exactly what you mean, but once you have added static text to a window, you can click on it and change the Alignment Property on the Visual tab. Also, it would be easier if you did not post the same question on multiple discussion forums. David Musgrave [MSFT] Senior Development Consultant MBS Services - Asia Pacific Microsoft Business Solutions http://www.microsoft...

Restoring files in 2006 money
Help! I am using MS 2006 money loaded from Dell on my new computer. I saved all my money files from my old computer and transferred into my documents (MS 2002 Money). When I go into 2006 and say restore files - it goes through the motions, but never brings up the data in the file. At the top of the page, it has the file name, but there is no data. I know the file has information in it - 3333kb. The sample file works, but I cannot get my old money files to come up. Please help, what do I need to do. Did you transfer backup files (.MBF extension) or, preferably, the Money data fil...

print preview command in Excel
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) I just upgraded to office 2008 for Mac and can not find the &quot;print preview&quot; command in Excel I had in my previous version and that is available in Word 2008. Was it removed? > On 11/4/09 8:43 AM, in article 59b7feef.-1@webcrossing.caR9absDaxw, <br> > &quot;sprint1005@officeformac.com&quot; wrote: <br> > <br> > > Version: 2008 <br> > > Operating System: Mac OS X 10.6 (Snow Leopard) <br> > > <br> > > I just upgraded to office ...

Unwanted "text to columns" when pasting text
Hi! I double-click a source cell, select some text in it and copy it via CTRL-C. Then I click a target cell and press CRTL-V to paste the selected text into this cell. However, EXEL doese an unwanted "text to columns" here, thus the text is not pasted into the target cell, but each word is pasted in a seperate cell. Example: Double-click cell A1, enter "A B" (A space B) in A. Press Return. Double-click A1 again, select the "A B" and press CRTL-C. Now click (once!) on cell B1, and press CRTL-V: In result, cell B1 contains the "A" while the "B"...

ESEutil commands
I need a step by step guide on using eseutil. I need to learn how to use this tool to commit the logs to the database On Tue, 23 Nov 2004 18:09:02 -0800, "Ed" <Ed@discussions.microsoft.com> wrote: >I need a step by step guide on using eseutil. I need to learn how to use this >tool to commit the logs to the database eseutil/? A full online backup of the store will commit the logs. What exactly are you trying to accomplish? I have another site that will not have a backup solution in place until next month so i would to know how to flush the logs using this utility ...

file recovery #5
If a file has changes made and has been saved and/or renamed, is there any way to revert to the old document or recover the old document? I am desperate. Using Office 2003. If it's been renamed using File/Save As..., the original file will be untouched since the last save. If the file was saved, however, unless you had it set to automatically create a backup, you're probably out of luck. In article <34d201c471a0$7400c4d0$a401280a@phx.gbl>, "rhonda" <cheers1050@aol.com> wrote: > If a file has changes made and has been saved and/or > renamed, is ...

Command Button #4
I'm trying to create a command button to clear filters in my spreadsheet. I don't know how to write the commands, but can recored a macro and run it fine. I tried pasting that macro into the button....and I had it working then messed it up. Now when I click on the button, nothing happens. The code currently associated to the button is below. I really don't want Criteria1 to = 'Reject', but the one time the button worked if no filter was set and the button clicked, an error was returned. The only way I could make it work was to force a filter as part of the macro. How...

restriict number of users in a group distribution list
hello the number rof users allowed in my distribution group at present is 500, i need to change it back to status quo . What can i please do ...

Kudos on the Quicken R3 Converasion Utility
People rarely take the time to acknowledge when something is done well. I'd like to thank the folks at Quicken (and Microsoft) for coming up with a great conversion utility. I know I'm likely to get flamed for this - but hear me out. I ran the conversion on a Money file that goes back to 2000 (and before for some investment accounts). I, like many, had an imperfect conversion. Numerous records were dropped. However, I inspected the items dropped and found an important fact: I had used these transactions incorrectly. All were cases where Money allowed me to create a tra...

valid rtf file that includes a dib
Hi there, that might be a little offtopic. But can somebody please post a valid rtf file that includes a dib section? Or does someone knows how to create one. I'm looking for a rtf file that uses the \dibitmap control word. I tried including an image using wordpad, but it uses some OLE stuff that I don't want to mess with. Thanks ahead, Christian ...

Finding X- & Y-intercepts of lines crossing curves
I created some charts with multiple data series by specifying certain points on the curves. THe series are displayed as lines. Now I want to draw (or specify the Y coordinates of) a horizontal line on the chart, & have Excel tell me the X intercepts where the horizontal line crosses each curve. Ditto for drawing a vertical line & reading Y intercepts Any ideas Thanks!! Hi Dale, Maybe you adapt my example of intersections. http://www.andypope.info/charts/intersection.htm Cheers Andy Dale wrote: > I created some charts with multiple data series by specifying certain points on...

How to space all lines in a paragraph evenly?
The lines in my text are sometimes spaced unevenly in a paragraph. Sometimes just the last two lines are spaced differently than the rest of the paragraph. I have tried kerning and all the other text and paragraph adjustments I can find. Could this possibly be due to too much text and graphics on one page? How can I find a solution to this. I have searched blogs and help all over. Are you creating the text box or are you using a template? There can't be too much text, if there is too much text you would get the overflow symbol on the bottom of the text box. Or maybe you have enable...

Multiple distribution lines on a PO for non-inventoried items
When we set up a PO for non-inventoried items, the distribution screen only allows one GL account for distribution. In the case where we want to buy a multiple quantity of an item (say Blackberries for example) and want to charge out each item to a different department, we either have to set up a line for each department's Blackberry, or charge them all to a single account and then redistribute by journal entry. This is a problem because in scenario #1, we have about 90 active departments - alot of keying and a very long PO if we have to set up a line for each one. In scenario 2,...

Text box placement in book layout
I'm trying (with emphasis on the word "trying") to typeset a book for a friend of mine. I've done it once before and it turned out well--but it was ten years ago and I used WordPerfect. The author has a text box that spans a couple of pages and I can't get the text box to behave. It seems to disappear in the "cracks" between the pages instead of flowing to the next page. I've tried everything I know and I still can't figure it out. What in the world can I do to get it to flow to the next page. I know I must be overlooking some simpl...

command
how do you use command. A lot of computer people use it but how do we use it? Aaron You've reached a newsgroup dedicated to supporting the use of Microsoft Access, a relational database product. I don't see anything in your post that suggests you are asking about MS Access. Please post to a newsgroup that supports the area covered by your post. Regards Jeff Boyce Microsoft Office/Access MVP "aaron" <aaron_t_d@hotmail.com> wrote in message news:78CB1423-55B3-40A1-8BF5-D4615E816057@microsoft.com... > how do you use command. A lot of computer people use i...

Outline numbering
I is possible to insert outline numbering to headings as with MS Word? We need to have headings that follow a 1.0 Heading 1.1 Sub Heading 1.2 Sub Heading 2.0 Heading pattern, but I cannot find a way of achieveing this. If this is not possible within Publisher, is it possible to link a Word file into Publisher dynamically, so that any changes within Word are then reflected in the Publisher file, whilst maintaining the outline numbering styles defined in the original Word document? It will have to be done manually in Publisher. Look at this example http://msauer.mvps.org/more_graph...

text selection bug?
Sometimes, when I copy paste from a web site I cannot make a selection of the lines of the text I pasted using the keyboard keys "left alt+left shift+up or down arrows". However I can select it using the mouse, but not using the keyboard. Is this a bug? On Jan 12, 7:38=A0am, "minimus" <mini...@live.co.uk> wrote: > Sometimes, when I copy paste from a web site I cannot make a selection of > the lines of the text I pasted using the keyboard keys "left alt+left > shift+up or down arrows". However I can select it using the mouse, but n...

Fatal Linker error: cannot open file "uafxcwd.lib"
attempting to compile common control sample CMNCTRL1, which Idownloaded from microsoft website. Linker error: fata error LNK1104:cannot open file "uafxcwd.lib". Platform is windows 2000 professional and Visual Studio 6 enterprise edition. Where can this library be found ? Probably you did not install the unicode libraries when installing visual studio (when I remember right, the default doesn't install them). Regards, Harald "Jagun Jagun" <anonymous@discussions.microsoft.com> schrieb im Newsbeitrag news:0a9401c39ee9$67fbf540$a401280a@phx.gbl... > attemp...

Text Overlapping Part of Grouped Objects
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I'm running into something that's confusing the heck outa me. I just tried to do something I've done hundreds of times now, grouping an image with a caption, so I can move them together. This last time, however, when I right-click, then select Group>Group, text below the group then moves up so that it overlaps the caption portion of the group (which is positioned below the image). <br><br>I've tried this several times now on this particular image and caption, with the same resu...

Hiding lines in detail
Hi, I'd like to hide a line when a field from a query = a 0 or IS NULL. Meaning: Client_name Bill# Total Joe Brown 123456 $1.500 (this line should appear) Joe Brown (this line shouldn't appear) HOWTO do it? TIA Ana Access 2003 Ana wrote: > Hi, > I'd like to hide a line when a field from a query = a 0 or IS NULL. > Meaning: > Client_name Bill# Total > Joe Brown 123456 $1.500 (this line should appear) > Joe Brown (this line shouldn't appear) > > HOWTO do it? > TIA > Ana > Acce...

command boxes from menu
I was working on word 2003, I had copied a portion of an online ebook to paste onto a new document, when I did right click to paste it on the doc. the command box appears outlined, no word commands, it's like a ghost. I then went to the menu at the top to Edit and find paste to do it from there and the same thing appeared; an outline of the command box, no word commands, it's like a ghost. I tried to pretend the words were there just not visible and moved my cursor to the position in which I thought paste was and clicked but nothing happened. Has anybody ever had this ...

EDB file to PST file?
Is there a utility (FREE) that I can convert an edb file to PST? I have some EDB files I want to take out some mail out of but not restore the whol thing. I test some COSTLY utilies but on need this for one time only. Thanks Mike What version of Exchange? Perhaps you could build a recovery server and do a disaster recovery scenario? -- Martin Blackstone MVP - Exchange http://www.swinc.com/resource/exchange.htm http://www.swinc.com/resource/e2kfaq_appxc.htm "Mike" <massey@rmci.net> wrote in message news:psst001mj15vod5fphqpfjc7hk39975d5l@4ax.com... > Is there a utilit...