Using rd and del commands.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Conk1
Posts: 12
Joined: 04 Dec 2009 09:43

Using rd and del commands.

#1 Post by Conk1 » 04 Dec 2009 10:04

Hello, I was wondering if the latter of commands is more effective:

rd /s /q "C:\temp\"

or:

del /f /s /q "C:\temp\*.*"
rd /s /q "C:\temp\"

Does adding the del command before rd makes it anymore effective or reliable for a directory of files?

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#2 Post by avery_larry » 04 Dec 2009 10:22

I'm not aware of anyway that would be better. Unless you have locked files. Then using the 2 commands might get more accomplished before erroring out with a locked file or something.

otherwise the del command is redundant.

Conk1
Posts: 12
Joined: 04 Dec 2009 09:43

#3 Post by Conk1 » 04 Dec 2009 10:30

Thanks for your reply :)

So the only benefit of using both lines would be that the timeout would be longer?

BILL Dos
Posts: 12
Joined: 22 Sep 2009 11:49
Location: USA

#4 Post by BILL Dos » 07 Dec 2009 19:04

You used rd /s /q "C:\temp\"
which is good if your system drive is Always C: but I perfer
doing the rd /s /q "%systemdrive%:\temp\"
That way you can have multiple drives and don't error out.

Conk1
Posts: 12
Joined: 04 Dec 2009 09:43

#5 Post by Conk1 » 07 Dec 2009 19:41

That is what I'm doing as well as other variables like %userprofile% and "localappdata% for vista.

Post Reply