command prompt batch files help

Jesusfrk611

Fully Optimized
Messages
2,193
Location
US
I have a class on command prompt in college. I'm on my last week finally. But I need to finish up 1 last assignment, and it's on batch files. I'm completely stumped.

Here's the question
Create a batch files called dd.bat. This batch file should display the files on the root of the disk (insert disk of your own, we use a floppy disk with all our assignments on it, but what is on it isn't important) in date order with the most current date displayed first, and should pause so that the user may view the display one screen full at a time. Document your name, name of batch file, and date.

I can do most of this stuff outside of a batch file, but putting it all together to make it work in a batch file...not getting it... I've been doing trial and error for awhile and can't figure out crap. We have a book with info for the chapter, but it doesn't seem to have the answers I need...

Thought I might throw that out there in case anyone knows command prompt that can help me out. Thanks.
 
DIR /O:-D /P <insert directory you want to search>

EDIT: I suppose I should explain what this does...

DIR searches and lists directories and files.
/O puts them in a search order of D which is by date.
To have them list newest first you must reverse the order.
That is what the - does.
/P pauses

All you need to do is insert the directory.


EDIT2: If you want ALL of the directories and files listed then you must add /S
If you want JUST files then add /A:-D with no /S

I guess all those years of batch file wars with friends paid off xD
 
Nice, it worked! lol, I dunno why that was so hard. I was trying to use the sort command in it and couldn't figure out how to sort the Directory of A:\ in the batch file for the life of me. :p I didn't pay close enough attention in that class except to just get through it... I did get to the /O on the DIR command at one point, but never got the -D. Thanks a bunch.
 
Back
Top Bottom