Copyright Michael Karbo, Denmark, Europe.


  • Next chapter.
  • Previous chapter.


    Chapter 25. More about scripts

    I have already in two places (see page 39 and 76) described small scripts, which can make different file processing tasks easier on a computer. It is, unfortunately, only in Windows XP Professional, that you can really take advantage of the command bar in full. But none the less I would like to give you a couple of tips for this facet in Windows XP. Because it is often, in fact, that a little batch file with a couple of commands can be the best solution for a specific task.

    You have to, however, be aware of the fact that the commands are powerfully potent and can, therefore, be devasting if they are used wrongly. You have been warned!

    Command prompt

    The text-based commands are called forth from small batch files, as we have seen. But they can also be run from a command prompt and this is smart for many purposes. Try this:

    1.    Type Windows+r to get the dialog box Run on screen. Then type in CMD Enter:

    2.    This gives a window with a flashing command prompt. You can use this window for looking at the different commands.

    3.    Try typing xcopy /? Enter. Then you will get a list of the different parameters, which work together with the command XCOPY.

    4.    Try examining the commands CHKDSK, CONVERT, ATTRIB and DEL yourself with the help of the parameter /?. They are all commands, which you might be able to use at some time or another.

    If you are interested in learning about more commands, you can study the EXE files in the folder \WINDOWS\system32. Many of them can be run from the command bar. But be careful commands can do a lot of damage to your computer's data, if you do something wrong by mistake.

    Figure 119. The command window.

    Examples of commands

    We have already seen the term File attributes. They are small codes, which are contained in every single file and which, for example, make it possible to give a file write protection. See Figure 66 on page 49. These attributes can be changed with the command ATTRIB, which can used as here:

    attrib -r -a -h -s C:\Temp\"Temporary Internet Files"\*.* /s /d

    This command task will remove all the attributes from all of the files in the folder C:\Temp\Temporary Internet Files and all its subfolders. Please note that that quotation marks are written around the name of the folder, where there is a space.

    Delete files with Del

    When all the attributes are removed from the contents of the folders, then most of them can be deleted. You can also use a command here.

    If we want to try to delete all the contents of the folder C:\Temp\Temporary Internet Files as well as all the subfolders, the command DEL (for delete) is used:

    del /q/s/f C:\Temp\Temporary Internet Files\*.*

    This and the previous command assume of course that there is a folder called C:\Temp\Temporary Internet Files. It's not certain that all the files are deleted, because some of them are probably in use in Windows and, therefore, locked.

    If we delete the whole of the folder C:\Temp as well as all its subfolders, then it can be done with a batch file as seen below. Three commands are used here. We have already seen ATTRIB and DEL in use; here RD is added, which stands for Remove Directory. Finally the folder is restored with the command MD (Make Directory). Altogether the four commands make an effective script. As far as possible, the folder is deleted and restored without content.

    Figure 120. Three commands, which together create an effective little cleaning script. But be careful that you don't clear away the wrong files!


  • Next chapter.
  • Previous chapter.


  • Book overview.