cancel
Showing results for 
Search instead for 
Did you mean: 

Dos Tutor for everyone

samuria
Grafter
Posts: 1,581
Thanks: 3
Registered: ‎13-04-2007

Dos Tutor for everyone

Having been in IT for over 18 years I grew up on DOS and naturally have used most of the DOS commands. Even today in Windows Xp and Vista DOS commands are very useful and often you can do things quicker than using the GUI. Having been an IT trainer most people who have never done DOS fail to understand a lot about files and the O/S. I thought some people may benefit from some basic DOS tutors and this will hopefully help them with their pc.
I thought a would do one tutor and if people find it interesting and ask for more then I can do some more.
Lets start by getting to DOS in XP or Vista there are to commands which differ slightly. First goto the start and then choose run and in the box type cmd and press return you will then get a box up with something like this, the mwright will be your username you have logged in with
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\mwright>
Its telling us its XP and you are in a folder or directory called Documents and Settings which is on drive c: and we are actually in a sub directory or folder called mwright. C:\ is the root of a windows system and all directories come from that. Think of it as a room you don’t throw all your letters on the floor you put them in a draw or directory or folder in this case its called Documents and Settings then to keep your files separate you put another box inside that one called mwright.
The second way to get a DOS prompt is to goto start run then type command and you then get a window like this.
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\DOCUME~1\MWRIGHT>
You will notice in this case the Documents and Settings has now become DOCUME~1 this is because DOS could only have 8 characters as a name so it now displays the first 6 and the rest is represented by ~1 the directory is  actually the same. To save confusion we will only use the cmd window or the article will be to long all you need to know is if you use the command then  you have to use only the first 6 characters of directories. So back to our cmd window.
We want to look at 2 commands the cd and dir.
CD is short for change directory and DIR is short for directory. Lets start with cd in the cmd window type
Cd\ and press return the display should change to c:\ so we have changed the currant directory from  Documents and Settings\mwright> to c:\.
Lets go back to were we came from by typing
C:\>cd\Documents and Settings\mwright replace the mwright with your name. you should now be back were you started.
How would we get to c:\windows?
Cd\windows the prompt gives you the current directory so you know were you are.
Lets go back to c:\ by typing c:\
Now for the second command DIR try it type dir and press return
What you will see is a list of files and some that say <DIR> the DIR are directories not files you will recognize windows, program files and some others you often use with explorer.
DIR list the files and directories and has what are called switches that is you can tell it how to display the file by adding / followed by a switch.
There are a fair few but try typing
Dir /w  and dir/p
The first one dir/w will display the files in a wide format and the /p will show one screen at a time and then you have to press a key to see more. DIR is a very useful tool and often faster than the GUI it can be used for as a search tool. DIR on its own displays all files but you can add switches to show just the files you want. So dir fred.txt will only show files called fred.txt.
Dir autoexec.bat will only display the files called autoexec.bat. Now the clever bit is if you are not sure of something you can say look for all the files ending in txt by using * as this represents anything. So dir *.txt will display all the .txt files. Dir text.* will show any file called text no matter what the extension is . dir *.* will show all files.
For those that don’t know a file has  a name a . and an extension the name after the .
The extension tells you what the file type is so a .txt is a text file a .exe is a program file which will run a programme a .doc is generally a word document. There are all sorts of extensions and you can make your own up if you want. Windows uses the extension to work out how it will open the file so If you click on a file with .txt windows will normally open it with notepad.
For our final trick lets use what we have learnt to do something useful make sure you are in c:\
Now we will use another dir switch /s type
Dir *.jpg /s and watch as the screen flashes bye      the /s tell it to display all files in subdirectories so what we have done is a full file search on drive c: for all pictures with a jpg extension but note how fast its displayed them.
So to see all txt files we do dir *.txt /s
One final trick the screen flashed by with loads of files to make matters simpler we can pipe the answer to a file by doing >filename
So if we now  do the same again but type
Dir *.jpg /s >pics.txt
You will then under up with a file in c:\ called pics.txt with a list of all your jpg files you can open this with word or notepad. If you did the command again it would overwrite the files but if you added another > it would add the files to the list so the command would be
Dir *.jpg /s >>pics.txt
I hope you have found this little article useful  let me know if you want more you have learnt
DIR
Cd\
How to open a dos or cmd window and use it to change directories
13 REPLIES 13
mal0z
Grafter
Posts: 3,486
Registered: ‎02-10-2008

Re: Dos Tutor for everyone

Great idea - thanks. Smiley
Likewise I started even before DOS - but not professionally in IT.
Also used DRDOS ( Digital Research )
found batch commands very useful
One thing I would like to know is how to convert from and to Windows long file names to the shortened DOS ones - if you could please.
Alex
Community Veteran
Posts: 5,500
Thanks: 921
Fixes: 13
Registered: ‎05-04-2007

Re: Dos Tutor for everyone

At work, we use DOS-based build tools, so it's something I have to use now and again but not too often.
Still good to keep up with the command line skills Wink
I think I discovered this by accident, but I figured out rather than having to type:
Quote
cd c:\a very long directory name with many spaces like program files

You can type:
Quote
cd c:\a very long*

Then it'll match the closest directory name.
Could be a Windows feature, as it works in XP and above in a Command Prompt. Not sure about a vanilla DOS.
community
Grafter
Posts: 666
Registered: ‎31-07-2007

Re: Dos Tutor for everyone

Great stuff, Samuria.
I started to learn dos commands when I bought my first computer, the Amstrad 640 portable, which I still have! together with a rather thick manual containing all the dos commands.
But I soon graduated to more modern (at the time!) computers and that is where my knowledge of dos ended.  Angry
I have needed to understand dos recently when I have experienced crashes and wanted to use a backup disk but unfortunately when I got the dos command coming up, that is when I bowed out  Roll_eyes
I only got a C prompt and didn't know what to do with it in order to get the pc up and running AND STILL DON'T...............
cheers
community
Grafter
Posts: 666
Registered: ‎31-07-2007

Re: Dos Tutor for everyone

Quote from: mal0z

Also used DRDOS ( Digital Research )

Your mention of DRDOS reminds me that , if I am correct, these are the people who were just pipped at the post by Bill Gates and his party.
I seem to remember that Gates was determined to get HIS o/s on the market before Digital Research and launched it together with all the bugs it still contained...hence the continuing problems we have with Microsoft..........
pierre_pierre
Grafter
Posts: 19,757
Thanks: 3
Registered: ‎30-07-2007

Re: Dos Tutor for everyone

I have been using it a lot recently, Get a generic update every Wed that includes file like pocketgps_uk_pmoblie.asc  unfortunately the using program only likes 8 letter prefixes and csv extensions.
I have approx 30 to manipuilate, the csv is easy  C:\ren *.asc *.csv  The second Is currently stumping me C:\ren pocketgps_uk_p*.* p*.*  doesnt work.  what should I be using
Also on my XP  in the Program list I have Accesories\comand prompt which bring up a "Dos" window.  and dont forget the last command is exit to get back to M$S
pierre_pierre
Grafter
Posts: 19,757
Thanks: 3
Registered: ‎30-07-2007

Re: Dos Tutor for everyone

just been trying to help myself and found this info program http://www.computerhope.com/  unfortunately didnt seem to answer my problem
pierre_pierre
Grafter
Posts: 19,757
Thanks: 3
Registered: ‎30-07-2007

Re: Dos Tutor for everyone

@Alex
When in dos  dont forget that to access a file name with included spaces you have to include the file name within parenthesis
i.e. "a long File Name"
Strat
Community Veteran
Posts: 31,320
Thanks: 1,609
Fixes: 565
Registered: ‎14-04-2007

Re: Dos Tutor for everyone

...or quotes Wink
Windows 10 Firefox 109.0 (64-bit)
To argue with someone who has renounced the use of reason is like administering medicine to the dead - Thomas Paine
pierre_pierre
Grafter
Posts: 19,757
Thanks: 3
Registered: ‎30-07-2007

Re: Dos Tutor for everyone

didnt want to say quotes some one might have got  the wrong end of the stick  (a piece of wood) Tongue Tongue
Strat
Community Veteran
Posts: 31,320
Thanks: 1,609
Fixes: 565
Registered: ‎14-04-2007

Re: Dos Tutor for everyone

I quite understand Wink You don't want to be accused of cross posting......and I did mean posting Wink
Windows 10 Firefox 109.0 (64-bit)
To argue with someone who has renounced the use of reason is like administering medicine to the dead - Thomas Paine
hailhail88
Newbie
Posts: 8
Registered: ‎03-12-2008

Re: Dos Tutor for everyone

try looking here http://www.theeldergeek.com/forum/index.php?showtopic=28753 for an answer to converting to the dos shortnames question
To complete long directory names when using cd try typing the 1st couple of letters of the directory name and then press TAB ..that completes the line too..press TAB again for the next directory alphabetically.
To prevent getting a dos 8.3 shortened directory structure use CMD rather than COMMAND, its the XP and Vista version of the command prompt (and NT and W2K for that matter)
TTFN
Rich
Grafter
Posts: 184
Registered: ‎30-07-2007

Re: Dos Tutor for everyone

There's loads of good DOS stuff on http://www.robvanderwoude.com/index.html
grimme
Grafter
Posts: 241
Registered: ‎01-08-2007

Re: Dos Tutor for everyone

I'd come across ones in the past that truncated long filenames to the 8.3 format by putting the files in the following format:
pocket~1.asc