Computing.Net > Forums > Disk Operating System > DELETING files across (Sub)Driectories

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.

DELETING files across (Sub)Driectories

Reply to Message Icon

Name: Renaissance Man
Date: July 2, 2001 at 17:08:48 Pacific
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: Jim
Date: July 2, 2001 at 20:01:04 Pacific
Reply:

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.


0

Response Number 2
Name: Secret_Doom
Date: July 2, 2001 at 20:09:08 Pacific
Reply:

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 files

That 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


0

Response Number 3
Name: Secret_Doom
Date: July 2, 2001 at 20:32:19 Pacific
Reply:

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

contents 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


0

Response Number 4
Name: Renaissance Man
Date: July 3, 2001 at 05:42:14 Pacific
Reply:

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!


0

Response Number 5
Name: Secret_Doom
Date: July 3, 2001 at 13:51:01 Pacific
Reply:

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/


0

Related Posts

See More



Response Number 6
Name: Renaissance Man
Date: July 4, 2001 at 16:29:23 Pacific
Reply:

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.


0

Response Number 7
Name: Renaissance Man
Date: July 5, 2001 at 04:02:07 Pacific
Reply:

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.


0

Response Number 8
Name: Secret_Doom
Date: July 7, 2001 at 18:11:45 Pacific
Reply:

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

new 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


0

Response Number 9
Name: Renaissance Man
Date: July 8, 2001 at 04:02:21 Pacific
Reply:

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?


0

Response Number 10
Name: Secret_Doom
Date: July 8, 2001 at 11:58:00 Pacific
Reply:

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

The switch /a-d will exclude the directories from the list

Try it. Please keep me informed!!!
See ya

-- Secret_Doom --


0

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 Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: DELETING files across (Sub)Driectories

Deleted Files on win98 Command prompt www.computing.net/answers/dos/deleted-files-on-win98-command-prompt/8794.html

Deleting Files by Date?? www.computing.net/answers/dos/deleting-files-by-date/10697.html

Using NT-DOS to automatically delete files that are too old www.computing.net/answers/dos/using-ntdos-to-automatically-delete-files-that-are-too-old/2585.html