Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to write a small batch file to delete a type of file (*.ptl) in a directory and all subdirectories, here is what I have:
del D:\directoryname\ /S *.ptl
however, the return gives me something like this:
Deleted file - D:\directoryname\file1.ptl
Deleted file - D:\directoryname\blah.lck
Deleted file - D:\directoryname\test.docMy question is, why is this deleting the *.doc and *.lck files as well as the *.ptl files i told it to?

This:
del D:\directoryname\ /S *.ptl
means del all files in D:\directoryname\
What you want is:
del D:\directoryname\*.ptl /S
OR:del /s D:\directoryname\*.ptl
=====================================
If at first you don't succeed, you're about average.M2

wonderful, thanks mechanix2go!
works in DOS, however that exact text placed into a batch file and double-clicked does not seem to work ... anything else I am missing here?

Run the batch at the prompt. If that works and double click fails, then something is very wierd.
=====================================
If at first you don't succeed, you're about average.M2

Good thing you have found the problem ... for future debugging reasons : set a "pause" command at the very end of the batchfile. If you always use this script via double-clicking, he will always show the (last) output of that script, probably including the error. This will override the "close on exit" feature of the Windows Explorer since the script is not finished ! It only is if you press any key. And because it is the last command, there is no functional difference anymore. So it doesnt bother the process. It does leave, on each of the occurance of any run, a window oncreen. But after debugging, you can remove this.
Instead of a "pause", you can also use a sleep, ex. "sleep 60". You may need to grab that somewhere from the net.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |