Computing.Net > Forums > Windows XP > Use Batch to sort lines in a text f

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Use Batch to sort lines in a text f

Reply to Message Icon

Name: Chester_Lou
Date: September 27, 2007 at 16:40:31 Pacific
OS: Windows 2000 Pro
CPU/Ram: Pentium D, 2 G RAM
Product: HP Media Center Edition
Comment:

Hello all

is there anyway to sort lines in a text file (eg. sorting lines to 1-9 a-z) by a batch file? thnx



Sponsored Link
Ads by Google

Response Number 1
Name: aegis
Date: September 27, 2007 at 17:04:25 Pacific
Reply:

I'm not sure it's what you want, but the virtual DOS has a sort command. It will sort the lines in a file by the first letter. To use it go to the command prompt and type something like the following:

sort "c:\folder name\filename.txt" > "c:\folder name\sorted.txt"

One line.


0

Response Number 2
Name: tonysathre
Date: September 28, 2007 at 00:04:34 Pacific
Reply:

This is my sorter. It does what you want but doesn't redirect STDOUT to a new file.
::==sorter.bat
@echo off
if "%1" == "" (
goto :_syntax
) else (
goto :_sort
)
:_sort
if not exist %1 (
echo %1 could not be found
goto :eof
)
rename %1 %1.bak
sort < %1.bak > %1
del %1.bak
goto :eof
:_syntax
echo USAGE: %0 filename
goto :eof

"Computer security." — Oxymoron


0

Response Number 3
Name: Mechanix2Go
Date: September 28, 2007 at 00:40:58 Pacific
Reply:

sort < myfile > newfile


=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


new malware.j Windows will not load



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Use Batch to sort lines in a text f

batch to Insert line to text file www.computing.net/answers/windows-xp/batch-to-insert-line-to-text-file/161650.html

need to do find and replace in a text file , www.computing.net/answers/windows-xp/need-to-do-find-and-replace-in-a-text-file-/175911.html

Batch to move the mouse by itself www.computing.net/answers/windows-xp/batch-to-move-the-mouse-by-itself-/167553.html