Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I'm running WinME (No comments, please!) I run a batch file at start up to delete known files I don't want. But I do not know how to delete types of files across multiple (sub)directories.
EXAMPLE: If I key in DIR *.TMP/S, I'll get a listing of ALL .TMP files in all directories and sub-directories. DELETE has no "/S" switch.
Can I include one or more lines in a batch file to delete all files with given extensions (like *.TMP and *.GID) in ALL directories and sub-directories? If so, how?

I think you might find that Deltree will do what you want, if it still comes with Win-ME.
Deltree will delete directories and contents.

yeah, right: deltree delets files in subdirectories... but it delets ALL of them, just in case you don't remember ;D
No kiddin now, I think R.MAN wants to del only the .tmp files, not all the filesThat can be done by batch.
Just give me some time
It should be ready by tomorrow-- Secret_Doom --
email: secret_doom@hotmail.com
PS: Any donatives should be put directly into my account. :D

Let's say it didn't take that long... :D
Here it goes!!!! It will delete all files within extensions GID and TMP at the C:\DATA directory and subdirectories.
You'll need EDLIN.exe. You may download it at
http://filebox.vt.edu/users/alrobin2/home/edlin/download.html
(don't be scared with the page)(put it in a directory path, such as c:\windows)You'll also need a complementar file, also posted below. You should put it at root (c:\)
contents of DELALL.BAT :
@echo off
dir/b/s c:\data\*.gid> out.bat
dir/b/s c:\data\*.tmp>> out.bat
edlin out.bat [lessthan] c:\delall.rep >nul
call out.bat
del out.bat
del out.bakcontents of DELALL.REP (has to be on c:\!):
1,#rC:\^ZDEL C:\
e
NOTE1: ^Z means CTRL+Z character. Get it in dos edit by CTRL+P+Z
NOTE2: [lessthan] mean lessthan character (the opposite of ">") this forum has problems in posting that character :P
NOTE3: Be careful with that! Any batchs that involves del/ren/move commands are very dangerous.That's it. Any further questions, letme know
-- Secret_Doom --
email: secret_doom@hotmail.com
PS: Only make changes on that batch if you know what your doing.
TIP: if ya want to edit it and are not sure of what you're doing, take out the three last lines from delall.bat. After running it, check out.bat. it should have a list of all files to be deleted (full path) with the command DEL on the begginnig of each line

Thanks, --Secret_Doom--. I think I understand most of it; could you explain what DELALL.REP does (it adds a delete command before each file listing, but I'm not sure how).
Is it possible to do this without Edlin? It seems like such a throwback.
I would have thought that wanting to delete files across (sub)directories would be something that many people would want to do, and that there would tons of already written batch files, but my two books on batch files (by Rubenking and Jamsa)don't even raise the question.
All MS had to do was to add an /S switch like it has in the DIR command.
Anyway, a very clever solution. I really do miss DOS!

Yeah, a /s switch at del would be great.
EDLIN is a command line text editor. It edits files, but has a different interface from notepad or edit. It is like dos. You give the commands. So, we can create a script file (delall.rep) to "guide" edlin to edit the file.
delall.rep says:
1,#rC:\^ZDEL C:\
"translation":
Replace every occurance of "C:\" by "DEL C:\"
1,# means that it will search for "C:\" from line 1 to the last line (so it will search the hole document)
That should be another ways, but that's the only one I know. And for that way, edlin IS necessary
-- Secret_Doom --
PS: For more information about using edlin.exe, go on:
http://www.wwwebspace.co.uk/~iskra/edlin/

Whoops! It doesn't work with long file names. One *.gid file was in C:\Program Files\Corel\[etc.] and got the error message "too many parameters - Files\Corel\Wordperfect." Apparently, as it comes across a space it thinks it's another parameter.

It also wants to delete directories that have a .TMP extention (e.g., msdownld.tmp). I guess that's ok, but it stops to ask permission to delete before continuing.

Hi there again!
I see, long names would be a problem...
But here is a solution:new DELALL.BAT :
@echo off
dir/b/s/l c:\data\*.gid> out.bat
dir/b/s/l c:\data\*.tmp>> out.bat
edlin out.bat [lessthan] c:\delall.rep >nul
call out.bat
del out.bat
del out.baknew delall.rep:
1,#rC:\^ZDEL "C:\
1,#r.gid^Z.gid"
1,#r.tmp^Z.tmp"
e
Now about the second trouble.. It asks for permission for deleting a file??? Are you sure???-- Secret_Doom --
PS: Please mailme or post a followup if you read this, so I may know you have readed it, since the post is kind of old

You are pretty good--enclosing the path in quotes!
There was one error in you last posting: you ask for a dir listing in lower case, then ask EDLIN to change upper case, which did not work. Took me a while to figure that out.
If DIR returns a directory and not a file, when out.bat runs, it give this message:
[without @echo off, if gives this line]Del "c:\windows\msdownload.tmp"
[with or without @echo off, it always gives these 2 lines]
All files in directory will be deleted!
Are you sure (Y/N)?Any ideas?

Hi there
Oops! Sorry, you're right, the first line of delall.rep is wrong! I think you have figured it out, but just in case.. it should be, like this:
1,#rc:\^Zdel "c:\
:)Now, about that problem... Its a little bit strange that in a dir like "*.tmp" there are directories. But now I have figured out whats hapenning:
you MAY put extentions at directories names.
There should be a directory with the name "msdownload.tmp", you see?now, I think this will solve the problem:
new (2) DELALL.BAT :
@echo off
dir/b/s/l/a-d c:\data\*.gid> out.bat
dir/b/s/l/a-d c:\data\*.tmp>> out.bat
edlin out.bat [lessthan] c:\delall.rep >nul
call out.bat
del out.bat
del out.bakThe switch /a-d will exclude the directories from the list
Try it. Please keep me informed!!!
See ya-- Secret_Doom --

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

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