View Single Post
Old 12-19-2003, 08:22 PM   #2
CREDO
Gruddammit!
 
CREDO's Avatar
 
Posts: 6,075
CREDO is "reptacular" (2,500+)CREDO is "reptacular" (2,500+)CREDO is "reptacular" (2,500+)
One need only type “deltree /?” to see a parameter list, but the answer to your question is simple. Deltree is designed to delete folders and subfolders recursively and files in those folders and subfolders, hence the name deltree as in branches of folders and subfolders in the form of a tree. You are not using deltree correctly. Deltree is supposed to have a directory as a parameter not a file, or in this matter (*.pk) which is a pattern for files.

All you need to type is “deltree /y c:\folder” and that will delete that folder including all the subdirectories. Or you can simply say “deltree /y c:\folder\.” That’s a fullstop at the end, meaning delete everything in the directory “folder”, including subfolders and files, but not “folder” itself. There is always the command “mkdir” if a directory needs to be created afterwards, but this should not be necessary using the previous method.

The DOS command “del” is for deleting files, again typing “del /?” will give one a list of possible parameters. You will see the switch /s which instructs the command to “delete specified files from all subdirectories”, therefore, using the command “del /f /s c:\folder\*.pk” will delete all the files in directories and subdirectories in the folder “folder”. The /f switch is simply to “force deleting of read-only files”.

Remember using deltree will delete folders and files recursively in a specified folder. Del is designed to delete files.

So in his batch file you can use:

----- Batch File Starts Here ---------
REM The following line deletes all pk files in the directory “folder” and in all subdirectories
del /f /s c:\folder\*.pk
------ Batch File Ends Here ------



I am the Law
CREDO is offline