Solved how do I do multiple sorts on a single data file

March 21, 2013 at 05:35:36
Specs: Windows
I need to create a batch script to sort this file by address field then by the lastname field. This is a columnar data file.

0SGzeWy0000003l 12345 NY 123 Anywhere St. Smith
0SGzeWy000000xO 88779 NY 455 Elswhere St. Jones
0SGzeWy000002Is 11712 NY 75 Pearl St. Claus
0SGzeWy000003Bl 11712 NY 74 Pearl St. Cooper
0SGzeWy000004lB 11712 NY 7 Pearl St. Lightyear
0SGzeWy000005eC 11712 NY 788 Pearl St. Mouse
0SGzeWy000006Xf 11712 NY 799 Pearl St. Duck
0SGzeWy000007Qh 11712 NY 7000 Pearl St. Mouse
0SGzeWy000008JQ 11712 NY 700 Pearl St. Duck
0SGzeWy000009ax 11712 NY 7 Pearl St. Lightyear


See More: how do I do multiple sorts on a single data file

Report •


#1
March 21, 2013 at 14:31:40
type aux1.txt | sort /+25

:: mike


Report •

#2
March 25, 2013 at 07:45:58
✔ Best Answer
thanks for the code. it worked. I directed the output to a folder using /o and when I place it in a batch script it loops and does not end. any ideas?

Report •

#3
March 26, 2013 at 18:21:39
post the script you're using.

Report •

Related Solutions

#4
March 26, 2013 at 18:25:21
type aux1.txt | sort /+25 /o out.txt

This is the script inside the bat


Report •

#5
March 26, 2013 at 19:40:51
sorry, I meant the "whole shebang" (ie: "the bat"). Aside from that, the code given works. In short, I think it's other (loop-control) problems with your batch, not this line.

Report •

#6
March 27, 2013 at 01:59:36
My bat is called sort.bat and the script inside is


type aux1.txt | sort /+25 /o out.txt


Report •

#7
March 27, 2013 at 06:23:16
IT looks like when I tried this it didn't create the file with the sort. I have never used sort /o aside from in this instance.

try adding.

if not exist out.txt echo.>out.txt

I am not sure if this is a normal instance with sort? or if its a glitch on my system? someone smarter and more experienced like nbrane

:: mike


Report •

#8
March 27, 2013 at 06:34:27
I can use the code from command line with no issues. The issue happens when I add it in a bat

Report •

#9
March 27, 2013 at 06:41:52
are you opening the batch in the same folder as the aux1.txt? You might try adding the path to the name and see if it fixes?

:: mike


Report •

#10
March 27, 2013 at 06:43:47
I do have the exact path now and still having the same issue when I run it.

type Y:\Process\Phase2\sortindex2.txt | sort/+25 /o Y:\Process\Phase2\sort1.txt


Report •

#11
March 27, 2013 at 10:54:46
@Mike, HA Ha! ;)
Ah, if your script is call sort.bat, then it may be calling itself. You might try renaming your script to something that's not a command. I made this mistake (if this is the issue, that is) with "rename" once, and it drove me batty.

Report •

#12
March 27, 2013 at 11:17:24
That was it! I renamed the bat to abc.bat and it worked. Thanks that was driving me nuts.

Report •

#13
March 27, 2013 at 11:41:07
Whew, thought I was going crazy, I had it work in a file and at the prompt, figured i was being a moron..I was, just for another reason. :D.

:: mike


Report •


Ask Question