Board logo

DOS Help
liam.mccaffrey - 20/8/09 at 02:08 PM

Can anyone help me decipher this script?

@echo off
dir %1 /-p /o:gn > "Directory Listing.txt"

exit

I know it generates a text file of the files in the directory in which it finds itself.

what do the %1 and /o:gn do?

thanks


Madinventions - 20/8/09 at 02:14 PM

The %1 is a command line parameter, so the user would type something like 'dir c:' and the script would replace the %1 with 'C:'.

/-p means do not pause after each screen of information.
/o lists the files in the given order. In this case, the given order is 'gn' which means 'Group directories first, then by name'.
Finally, the '>' means route the output somewhere other than the screen - in this case it goes to your text file.

I love DOS and still use batch files like this every day!

In WinXP, click Start, then Run and type in 'cmd' into the box. This will give you a DOS box. Now type 'dir /?' and you will get a list of all the options for the dir command.

Best regards,
Ed.


m8kwr - 20/8/09 at 02:15 PM

/o which puts directories in a specified order

:n which sorts by name, alphabetically

:g which sorts with subdirectories appearing first

HTH


Madinventions - 20/8/09 at 02:17 PM

Oh, if you wanted just a list of files rather than all of the othe time and date info too, you could put a /b into the file.

dir %1 /b /-p /o:gn > "Directory Listing.txt"

HTH,
Ed.


liam.mccaffrey - 20/8/09 at 02:21 PM

thank you very much, i like them too

I would to use them more often


MikeR - 20/8/09 at 03:56 PM

I clicked on this link as I spent last week writing dos batch files in XP.

Reminds me of the old days and there are only a few of us left who can do it at my place. (ok, maybe thats a few who are prepared to do it).

Today .... i've been installing BUGZILLA! woohoo (the main bit of the whoohoo is the fact in 5 hours in between my normal work I've got it installed where as one of my colleagues failed solidly over 3 days )

geeks rule!


MikeRJ - 20/8/09 at 03:59 PM

quote:
Originally posted by MikeR
Today .... i've been installing BUGZILLA! woohoo (the main bit of the whoohoo is the fact in 5 hours in between my normal work I've got it installed where as one of my colleagues failed solidly over 3 days )



He needs to raise this issue on the bug tracking system. Oh wait...


stevebubs - 20/8/09 at 06:27 PM

quote:
Originally posted by MikeR
I clicked on this link as I spent last week writing dos batch files in XP.

Reminds me of the old days and there are only a few of us left who can do it at my place. (ok, maybe thats a few who are prepared to do it).

Today .... i've been installing BUGZILLA! woohoo (the main bit of the whoohoo is the fact in 5 hours in between my normal work I've got it installed where as one of my colleagues failed solidly over 3 days )

geeks rule!


Mike,

have you had play with MS' Powershell yet?


Agriv8 - 20/8/09 at 07:48 PM

Had to look up the switch commands up but starting to show my age when i will still get a machines IP details from dos.

PS 1 I found the other day ping with a -t switch ( continuous ) fire 3 or 4 of these of on a test machine while doing networky stuff absoloute godsend.

PS my wife has just called me a nerd !!! Yup and proud !!

Regards

Agriv8


maxey74 - 20/8/09 at 08:05 PM

I too am old, and as such, an utter command line whore! It has a certain cool factor though, at least it does if you're a professional geek, like me

Some fairly technical guys here by the looks of it... Assuming some of you work in IT?


stevebubs - 20/8/09 at 08:32 PM

quote:
Originally posted by Agriv8
Had to look up the switch commands up but starting to show my age when i will still get a machines IP details from dos.

PS 1 I found the other day ping with a -t switch ( continuous ) fire 3 or 4 of these of on a test machine while doing networky stuff absoloute godsend.

PS my wife has just called me a nerd !!! Yup and proud !!

Regards

Agriv8


For ping tests, go and get pingplotter ...


David Jenkins - 20/8/09 at 09:16 PM

I recently wrote a DOS batch script that did a particular copying job - my office is full of ace C# programmers aged between 25 & 35, and none of them had seen it done before (which I found hard to believe, but there you go). They were all set to write a bit of code to do the same job, and I'd done it in 10 minutes...

If like me you run a Linux box at home then the command line holds no fears, especially when you remember that MS-DOS is only emasculated UNIX.

Another proud nerd!


MikeR - 20/8/09 at 10:57 PM

Ok, wrote a batch file last week that .....

Scanned running processes and terminated one if it was running,

Scanned running "at" jobs (scheduled jobs) removed the ones i didn't want and replaced them with new jobs.

oh and it also renamed a file and took a setting out of the registry.

I was happy and so was my customer that it didn't involve c / delphi code changes as that would have to go through a different process & take time / incur costs.

Stevebubs - i haven't played with powershell much at all, one of the 'old school' lads runs out entire build machine on it. Does some pretty nifty stuff by all accounts.

Technically i'm not a geek, i'm a project & support manager. I just have a geek background (ex developer) and still love getting my hands dirty.