• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

Need to learn DOS

Hi,
I am a newbie ...

My friend help me rename all files in a folder .He using command prompt and do it...

I like to learn few basic things about the dos... how to use it ..WHat are the basic commands etc..

Any help...
0
coolguy2009
Asked:
coolguy2009
  • 5
  • 2
  • 2
  • +1
5 Solutions
 
TextReportCommented:
Don't forget the HELP command in DOS will prompt you with alot of the built in commands.
Using a /? will ofter provide help with the specific command such as XCOPY /?

Cheers, Andrew


0
 
BillDLCommented:
May I offer you some advice BEFORE you embark on your first adventure into DOS?

Don't start testing it on the computer that you use every day for essential tasks unless you have a backup and/or a quick way to restore it to what it was.

You see, some DOS commands can be particularly powerful and you could end up deleting, moving, or renaming important folders or files, or associating file types with the wrong programs, just by making a very small mistake in the command.  Probably the safest thing to do would be to create a separate folder to test things from within.

A couple of important thing to know, and these may be indicated in some of the links already given, are:

1. In general, DOS is not case-sensitive.  COPY works the same as CoPy or copy

2. In some instances, and certainly if you are using DOS on a Windows 98 computer rather than the DOS-like command line in Windows XP, file and folder names that contain spaces can cause problems.  If you have a path, folder name, or file name with one or more spaces, surround that path or file/folder name with double quotes.

3. There are Internal commands, External commands, and those that only work in batch files.  DOS in anything up to Windows ME uses "command.com" as its main program.  Later than that you will find this is replaced by "CMD.EXE".  Some commands are actually inside that program, and others are standalone program files in the system folder used to contain them.  Win98 stores its DOS program files in the C:\Windows\Command folder, and XP stores them in the C:\Windows\System32 folder.

4. A Batch Program (either *.BAT for Win9x or XP, or *.CMD XP only), is just a text file containing one or more command lines that are executed in sequence.  Some "commands" that you may see listed in online help pages discussing this are only usable in batch files, for example GOTO, CLS, REM.

Don't be terrified of DOS, be careful, that's all.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
coolguy2009Author Commented:
Yes i will make a separate folder and then try the DOS...

Also what is .bat ?

It is a coding(dos).How to run this?
0
 
dirtysnipeCommented:
Here is the wiki on bat files

http://en.wikipedia.org/wiki/.bat
0
 
BillDLCommented:
coolguy2009

That is a good link given by dirtysnipe, and it shows a good simple batch file to start off with.  In teaching different programming languages it is normal for the person learning it to create a program that just shows "Hello World" on the screen.

You may hear people referring to a "batch script".  In programming, a "script" is just one or more commands in plain text that can be run as a program.  So a batch file or batch script runs as a program, or at least it should run as a program if it is written properly.

Windows knows what to do with batch files that have the .BAT or .CMD file extension.  Double-clicking on the batch file should run it as a program, but in most company workstations standard users may be prevented from running batch files, and they may open up in Notepad instead.

It is possible that you are not seeing the .BAT or .CMD file extensions on your computer.  To ensure that you are seeing them, you should open "Folder Options" which is either in your Control Panel or in Windows Explorer on the "Tools" menu.  In the "View" tab, if the box named "Hide extensions for known file types" is ticked, then UNtick the box and click the "Apply" button.

When you can see the file extensions, you can do one of the following things to create a batch file:

1. Create it in Notepad then do a File > Save As, and save as a *.txt file.  Close Notepad, Right-Click on your saved *.txt file, and choose Rename.  Change the .txt file extension to .bat or .cmd and accept the warning about changing file types.

or

2. Do a File > Save As in Notepad, change the "Save As Type" line to show "All Files", and give your file the name including .bat or .cmd at the end.  The other way, if you just leave the "Save As Type" field set to *.txt files, is to type your new file name (including the .bat or .cmd at the end) and enclose the file name in " "

In the "Hello World" batch file shown on dirtysnipe's linked page, you will see the PAUSE command at the end of the batch file.  I suggest you add this to the end of all your batch files for now.  You want to see what is shown on screen as the batch file runs, and often a batch file will just run and close its "DOS" window when it finishes unless you stop it with the Pause at the end.

I suggest that you first begin practicing DOS by opening a new DOS window (command window) and try navigating up and down through folders using the CD command (change directory).

If you have Windows XP, then your new Command window will open with the "Prompt" showing you to be currently in your own "profile" directory, ie.
C:\Documents and Settings\YourName>

To change directory right back to the root of the C: Drive and show the C:\> Prompt, just type   CD  \

To change directory back up by one folder (in this case to the C:\Documents and Settings> Prompt) jst type   CD  ..

To show just the sub-folders of the current directory (ie. what is showing in the Prompt), just type   DIR  /ad  /b

You can then choose a folder, for example DESKTOP  and change directory to your  C:\Documents and Settings\YourName\Desktop> folder by typing the command    CD  desktop

and then display all files and folders on your Desktop (in sorted order using /on ) using the command    DIR  /on /b /s *.*

As stated earlier, to get help with any command, just type the name of the command followed by a space and then  /?   for example, to see the other available "switches" ) like the /ad /on /b /s shown in the commands above, just type   DIR /?

If you want to save the details of the help for a particular command as a text file that you can open in Notepad and print out, you can instead send the screen display to a file (called redirection) using the > symbol and the file name you want to send the screen content to:

DIR /? > C:\My_DOS_Stuff\Dir_Usage.txt

If the folder was named eg.   C:\My DOS Stuff   (with spaces), then you should add " " around the path:

DIR /? > "C:\My DOS Stuff\Dir Command Usage.txt"

This too is true if you specify any path, folder name, or file name that has spaces.  For example if you were at the C:\> Prompt and wanted to move into the  C:\Documents and Settings\coolguy2009\Desktop  folder, you would use these commands to get there:

CD "Documents and Settings"
CD coolguy2009
CD Desktop

You could also get there in one step using the command:

CD "Documents and Settings\coolguy2009\Desktop"

Windows XP is actually very good at handling names that contain spaces, but it is always good practice to include the " " around anything with spaces.

What I suggest is that you create your own practice folder and then create a number of sub-folders in it.  You can then create some test files in those folders while you are learning.  That way you can safely ename, delete, copy, or move any of your test foldersor files without potentially screwing up your computer.

I hope these notes help you.
0
 
BillDLCommented:
I should have mentioned the *.* in the above comment.  If you are not already aware, eg. from ghaving used Windows search to find specific files, the * is like the Joker in a card game.  It can be anything you want.

So, if you searched your hard drive in Windows for files named   *coolguy*.jpg   it will find all .jpg image files with "coolguy" somewhere in the name.

*coolguy.jpg   would only find files where "coolguy" was the last part of the file name before the .jpg extension.

coolguy*.jpg   would find all .jpg files that start with "coolguy" but may have something else in the file name before the .jpg extension.

*coolguy*.*   would find all file types with "coolguy" anywhere in the file name.

This works just the same at the command prompt, and therefore in batch files too, but you should be very careful with the * character.  Look at the following command:

REN  *.txt  *.jpg

That would rename ALL .txt files in the current folder to .jpg files, and would not stop to ask you if you really wanted to do such a stupid thing.

DEL *.txt

would DELETE ALL .txt files in the current folder.

DEL  *.*

Would DELETE ALL FILES of all file types in the current folder, and may not ask you whether you needed to keep them!!

This is what I was saying earlier about why DOS can be very useful (as your friend showed you when renaming files in a folder), BUT can also be very powerful and dangerous unless you know what you are doing.
0
 
coolguy2009Author Commented:
It is very good and easy for me...Thanks guys...
0
 
BillDLCommented:
Thank you coolguy2009.

I'm just thinking about your Experts-Exchange login name.  In 2010 you might stop being cool, and people might think of you as the guy who used to be cool last year ;-)
0
 
BillDLCommented:
One last thing, and you have probably discovered this already.  To open up a *.BAT or *.CMD batch file in Notepad to view or edit it, just Right-Click on the file and choose "Edit".
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now