PC Review


Reply
Thread Tools Rate Thread

Command Line Utility to split text file by number of lines

 
 
dingdongdingding
Guest
Posts: n/a
 
      6th Apr 2010
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.
 
Reply With Quote
 
 
 
 
LD55ZRA
Guest
Posts: n/a
 
      6th Apr 2010

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.
 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      6th Apr 2010
"dingdongdingding" <(E-Mail Removed)> wrote in message
news:85c44ac3-bb4f-4dbe-a629-(E-Mail Removed)...
> 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"

 
Reply With Quote
 
Nil
Guest
Posts: n/a
 
      6th Apr 2010
On 05 Apr 2010, dingdongdingding <(E-Mail Removed)> 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.
 
Reply With Quote
 
dingdongdingding
Guest
Posts: n/a
 
      7th Apr 2010
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-(E-Mail Removed)...
>
> > 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"


 
Reply With Quote
 
dingdongdingding
Guest
Posts: n/a
 
      7th Apr 2010
Unix has this split command. Can't find the windows equivalent.

On Apr 7, 12:31*am, 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. *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.


 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      7th Apr 2010
This is exactly the way I wrote it. As I said, your spec was somewhat vague
and allowed several interpretations.

"dingdongdingding" <(E-Mail Removed)> wrote in message
news:9cc8f67f-8704-4443-98e5-(E-Mail Removed)...
> 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-(E-Mail Removed)...
>>
>> > 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"

>

 
Reply With Quote
 
Nil
Guest
Posts: n/a
 
      7th Apr 2010
On 06 Apr 2010, dingdongdingding <(E-Mail Removed)> 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.
 
Reply With Quote
 
dingdongdingding
Guest
Posts: n/a
 
      8th Apr 2010
Thanks. I think the split from http://openetwork.com/berk.html is good
for me.

Thanks everybody !

On Apr 7, 11:46*pm, Nil <redno...@REMOVETHIScomcast.net> wrote:
> On 06 Apr 2010, dingdongdingding <dingdongdingd...@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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Split large text file by number of lines? ivan.perak@gmail.com Microsoft VB .NET 4 1st Mar 2007 07:46 AM
Command Line Utility to manipulate file names flahmeshess Microsoft Windows 2000 11 20th Nov 2005 12:32 AM
NEED: Command line utility to get graphics dimensions of text output in a specified font Carol Haynes Freeware 3 6th Nov 2005 08:30 PM
Command line utility to give graphic dimensions of text string in specified font Carol Haynes Windows XP General 0 6th Nov 2005 05:29 PM
Looking for command line file purge utility Klaus Windows XP General 2 4th Nov 2004 09:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:56 PM.