Sorting in VB script or DOS

September 10, 2009 at 22:39:45
Specs: Windows 2003
Hi,
I have a VB script which is accessing a file of .jrn extension with data as below:

File_name.jrn

DOC|0|Group1|95465|1|4|0000004382|acctr14|4|56329|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|21345|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|81943|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|48963|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|56329|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|12345|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|59436|

I need to sort the text above with in the file based on the last column(highlighted) which is composed of numbers alone through VB script or DOS command.

Expected result:

File_name.jrn
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|12345|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|21345|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|48963|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|56329|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|56329|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|59436|
DOC|0|Group1|95465|1|4|0000004382|acctr14|4|81943|


Can some one please suggest me a way forward to do the same as this is subject to my delivery now.


See More: Sorting in VB script or DOS

Report •


#1
September 11, 2009 at 06:29:23

@echo off
sort /+45 Filename.jrn /O Filename.tmp
copy Filename.jrn Filename_old.jrn > nul
ren Filename.tmp Filename.jrn
  YOUR VBScript
:: End_Of_Batch


Report •

#2
September 11, 2009 at 13:53:36
I hope the above post may help.

Report •

#3
September 13, 2009 at 19:06:08
There is dos sort and other utilities than can do positional sort or multiple sort keys.

Report •

Related Solutions

#4
September 14, 2009 at 21:38:49
Hi,
The dos sort suggested above is not handy in my case as each of the field in the journal file is of dynamic length, hence "/+45 " cannot be used.
Please suggest an alternative if available.

Report •

#5
September 16, 2009 at 03:57:46
From your original post I assumed fixed lenght fields separated by pipe (|). If the journal is a text file with fields separated by a specific delimiter a solution by batch scripting is still possible.

Report •


Ask Question