Classic Computer Magazine Archive COMPUTE! ISSUE 156 / SEPTEMBER 1993 / PAGE 50

Move and Deltree. (IBM DOS 6.0 disk-management commands) (Introdos) (Column)
by Tony Roberts

They've been a long time coming, but Microsoft's new DOS has a couple of important disk-management tools - Move and Deltree - that shouldn't be overlooked.

Unless you already have some kind of a file mover on your system, getting a file from one place to another is a three-step process: First, you copy the file to its new location; second, you check to see that the copy was successful; and third, you delete the file from its original location.

With DOS 6, you can accomplish the move in a single command. The syntax is Move filename destination.

To move more than one file, you can use wildcards, as in Move*.TXT C:\TXTFILES. If wildcards won't work, explicitly name all the files you want to move, separating the source filenames with commas: Move AUTOEXEC.BAK, CONFIG.BAK C:\BACKUPS.

DOS informs you if the destination subdirectory doesn't exist and asks if you want to create it. This feature saves time, but it comes back to haunt you if you attempt to move files to the root directory. For some reason, DOS doesn't know that the root directory exists and asks, Make directory c:\? [yn]. Although you know the root directory exists, press Y and the files will be moved.

Move, like its older cousin Copy, doesn't warn you if the files you're moving will over-write files of the same name. This requires that you know what files exist on the destination end of your move.

With Move, it's also possible to rename a file as it's being moved, but only if you're moving a single file. The syntax that accomplishes this is Move OLDNAME.EXT C:\DEST\NEWNAME.EXT.

Use this trick to rename a subdirectory, too. For example, use Move C:\SEP93 C:\OCT93 to rename your monthly project subdirectory.

Note that Move isn't as complex as the "prune and graft" commands found in some file managers. All Move can do is change the name of the subdirectory; it can't change its position on the directory tree. To relocate a directory full of files on the directory tree, create the new subdirectory, use Move to put the files in the new location, and then remove the old subdirectory.

Since the old subdirectory is now empty, it will be easy to remove it the traditional way - with RD. However, when circumstances call for you to delete subdirectories full of files, you'll want to use DOS 6's Deltree command.

Prior to DOS 6, removing a subdirectory could be a chore. DOS wouldn't remove a subdirectory containing files, so you had to erase the files before using RD. If the subdirectory contained hidden files, the DOS Erase command missed them, but RD knew they were there and refused to delete the directory. So, you had to use the Attrib command to make the hidden files visible and then erase them before you could remove the subdirectory. If you had subdirectories nested within subdirectories, you had to start at the lowest level and repeat this process as you worked your way up.

Deltree untangles this sticky web. Typing deltree path wipes out the subdirectory, all of its files - including system, hidden, and read only - and the subdirectories nested within it.

It's powerful, but dangerous, so make certain you know what you're doing. Even Undelete running in Delete Sentry mode can't bring back files that were stored in deleted subdirectories.

Normally, unless you use the /y switch, Deltree will ask for a confirmation before it takes any action. Sometimes, though, it returns to the DOS prompt without saying anything. This simply means that Deltree didn't find the subdirectory you specified. You may have made a typo as you entered its name or failed to identify the entire pathname. Try again. If you're successful, you'll receive a confirmation request followed by the message Deleting pathname. . . .

Deltree suffers from some other anomalies. First, if you try to delete the current subdirectory, Deltree's messages will indicate that it's being done, but the operation won't be complete. The files and any subdirectories will be removed, but the active subdirectory won't be deleted. Second, if the subdirectory you're removing has any of its attributes set, Deltree thinks the subdirectory is a file and prompts you with Delete file "filename"? [yn]. Although the prompt is erroneous, Deltree takes the expected action and deletes the specified subdirectory.

Finally, either one of these commands can help you correct an illegal-directory-name problem. For example, although spaces aren't allowed in directory names, some applications or installation programs manage to create directory names with spaces in them.

To delete such a directory with Deltree, place quotation marks around the directory name when typing the Deltree command: deltree "93 data".

If you just want to change the directory name so it's legal, use Move, again surrounding the illegal name with quotation marks when you enter it: move "93 data" data.