Computing.Net > Forums > Programming > batch file to delete

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file to delete

Reply to Message Icon

Name: fleetmack
Date: August 3, 2007 at 08:50:59 Pacific
OS: win2003 server
CPU/Ram: alot
Product: new
Comment:

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.doc

My question is, why is this deleting the *.doc and *.lck files as well as the *.ptl files i told it to?



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: August 3, 2007 at 09:22:45 Pacific
Reply:

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



0

Response Number 2
Name: fleetmack
Date: August 3, 2007 at 10:51:45 Pacific
Reply:

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?


0

Response Number 3
Name: Mechanix2Go
Date: August 3, 2007 at 11:51:32 Pacific
Reply:

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



0

Response Number 4
Name: fleetmack
Date: August 3, 2007 at 12:33:28 Pacific
Reply:

seems to work fine now, i think it was an ID 10-T error ;)


0

Response Number 5
Name: User123456789
Date: September 9, 2007 at 06:38:38 Pacific
Reply:

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.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file to delete

Batch File To Delete Line www.computing.net/answers/programming/batch-file-to-delete-line/15539.html

Batch file to delete files in a dir www.computing.net/answers/programming/batch-file-to-delete-files-in-a-dir/14599.html

Batch file to delete profiles www.computing.net/answers/programming/batch-file-to-delete-profiles/16684.html