Talking Shop: Manage Windows 2000 files with the FIND and RD console commands

Learn how the FIND command can be used to locate a text string within a file and how the RD command makes quick work of directory deletion.

While the Windows 2000 GUI makes file and directory management easier than ever, there are still times when a console command can do the job a little faster, or perhaps there are times you just prefer to use the console. In this article, I'll explain two tips to help hone your Windows 2000 console command skills. Learn how the FIND command can be used to locate a text string within a file and how the RD command makes quick work of directory deletion.

Find text in files with FIND
In Microsoft Word, you can perform advanced searches for documents that contain specific words or strings that meet other search criteria. Word searches multiple file types including all Office types, text files, Web pages, and more. If you don't have Word or simply prefer to search from a command console instead, Windows 2000 offers a couple of command-line tools you can use to search text files.

The first is FIND, which searches for a text string in one or more files. FIND can display all lines containing the specified string, display all lines not containing the string, or show the count of lines containing the string. FIND can search the text typed at a command prompt or piped in from another command and can also search a file. Open a command console and type HELP FIND for syntax and options.

The second tool for text searches is FINDSTR, which provides several additional options not included in the FIND command. For example, FINDSTR can list only filenames for files that contain the specified string and can take the list of search strings and search paths from text files. This is particularly handy when you need to perform a complex search or if you need to perform a search on a regular basis and don't want to type the information each time. You can view the syntax and options for FINDSTR by entering HELP FINDSTR at a console prompt.

Delete directories with RD
It's a breeze to delete entire directories and their contents within the Windows 2000 GUI: Select a folder and type DEL. This moves the directory and its contents to the Recycle Bin. If you want to bypass the Recycle Bin and delete the files immediately, hold down [Shift] when you type DEL.

In some cases, you might need to delete directories from a command console. For example, you may prefer working from a console prompt or need to delete several unrelated directories and want to accomplish that task with a batch file. Although you could use multiple DEL commands, the RD command—synonymous with RMDIR—is a better choice.

The RD command removes all files and directories in the specified directory and then removes the specified directory. The syntax for RD is: RD [/S] [/Q] [drive:]path.

When you use it without switches, RD removes only the specified directory, if that directory is empty. The /S switch causes RD to remove all subdirectories and files and then remove the specified directory. The /Q switch runs RD in quiet mode, in which RD does not prompt you to confirm the deletion of directory trees.

A word of caution: Make sure you know what you're doing when you use RD with the /S and /Q switches. If you're not careful, you can easily remove critical directories in the blink of an eye.

Are you still a DOS nut?
We want to know if you still use DOS. Are there still tasks that only DOS can accomplish? Post a comment to this article and share your DOS tips and tricks.


Editor's Picks