Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

dir/date by YYYY-MMM-DD

SOLVED
Go to solution
Stephen Daddona
Frequent Advisor

dir/date by YYYY-MMM-DD

I have a need to show files in a directory sorted by date. I wrote a hokey DCL procedure to do that, but I was wondering if there's a way to tell the DIR command to output the date in YYYY-MMM-DD format instead of DD-MMM-YYYY. That way I could just send the output to a file and then sort it.

Thanks!
7 REPLIES
Jess Goodman
Esteemed Contributor

Re: dir/date by YYYY-MMM-DD

Yes, just do:

$ DEFINE LIB$DT_FORMAT -
LIB$DATE_FORMAT_037,LIB$TIME_FORMAT_001
I have one, but it's personal.
Jess Goodman
Esteemed Contributor

Re: dir/date by YYYY-MMM-DD

I should have mentioned that you need to execute this command if it is not already in one of your system startup files:

$ @SYS$MANAGER:LIB$DT_STARTUP
I have one, but it's personal.
Hein van den Heuvel
Honored Contributor

Re: dir/date by YYYY-MMM-DD


I like making dir output sortable dates.

But you can also teach sort how to do dates.

Here is the core from an old procedure which I first saw back in 1991 created by Eric Osman @ Digital.

$ pipe dir/col=1/wid=fil=55/nohead/notrai/date | sort/spec=sort_by_date.sort sys$pipe sys$output

----------- sort_by_date.sort -----------
/collating_sequence=
(
sequence=("AN","EB","AR","PR","AY","UN","UL","UG","EP","CT","OV","EC",
" ","0"-"9"),
fold
)
! second and third letters of each month

/field=(name=year,pos:65,size:4)
/field=(name=month,pos:62,size:2) ! start at SECOND letter
/field=(name=day,pos:58,size:2)
/field=(name=time,pos:70,size:11)
! assume "14-OCT-1986 09:14:46.00" at position 58
/key=(year,descending)
/key=(month,descending)
/key=(day,descending)
/key=(time,descending)


Cheers,
Hein.
Stephen Daddona
Frequent Advisor

Re: dir/date by YYYY-MMM-DD

Jess,

I just found that out! Thanks!
Robert Atkinson
Respected Contributor
Solution

Re: dir/date by YYYY-MMM-DD

Craig, there's a utility by K.G.G. Clippeleyr called QDSB which enhances the DIR command and allows for different sorts :-


QDSB

/SORTED_BY

/SORTED_BY=(keyword[,...])

Presents the information sorted according to several criteria. The
following keywords are allowed:

NODE
List of files is sorted by node specification (currently
unsupported).

DEVICE
List of files is sorted by device specification.

DIRECTORY
List of files is sorted by directory specification.

NAME
List of files is sorted by filename.

TYPE
List of files is sorted by file type.

VERSION
List of files is sorted by version (descending order is the
default).

FILE_ID
List of files is sorted by file identification (by default
ascending on RVN, then on FID).

OWNER_ALPHANUMERIC
List of files is sorted by the alphanumeric representation of the
owner of the files.

OWNER_NUMERIC
List of files is sorted by the numeric representation of the owner of the files.

SIZE_USED
List of files is sorted by the size of the files.

SIZE_ALLOCATED
List of files is sorted by the allocated size of the files.

DATE_CREATED
List of files is sorted by the creation date of the files.

DATE_MODIFIED
List of files is sorted by the revision date of the files.

DATE_EXPIRED
List of files is sorted by the expiration date of the files.

DATE_BACKUPED
List of files is sorted by the backup date of the files.

DATE_EFFECTIVE
List of files is sorted by the effective date of the files.

DATE_RECORDED
List of files is sorted by the recorded date of the files.

DATE_ACCESSED
List of files is sorted by the date the files were last accessed.

DATE_ATTRIBUTES_MODIFIED
List of files is sorted by the date the attributes of the files
were changed.

DATE_DATA_MODIFIED
List of files is sorted by the date the contents of the files were
changed.


Each keyword can be accompanied by two other keywords:

ORDER
ORDER=ASCENDING (the default, except for VERSION), indicates the
information must be sorted in ascending order.
ORDER=DESCENDING, indicates the information must be sorted in
descending order.

PRIORITY
PRIORITY=n, where 'n' is a positive integer number, indicates the
priority of the item in the sort operation; the lower the value,
the higher the priority.


Rob.

Kris Clippeleyr
Honored Contributor

Re: dir/date by YYYY-MMM-DD

Craig,

As Robert mentioned (thanx) the QDSB utility is downloadable from our website ( www.quadratrix.be , look in the Products section). A new version (V0.3) is coming up (I'm polishing it right now).

Regards,
Kris (aka Qkcl)
I'm gonna hit the highway like a battering ram on a silver-black phantom bike...
Stephen Daddona
Frequent Advisor

Re: dir/date by YYYY-MMM-DD

I got QDSB and tried it, and it works great!


Thanks!