3 Replies - 3240 Views - Last Post: 20 April 2010 - 08:58 PM

#1 RandomlyKnighted   User is offline

  • D.I.C Lover
  • member icon

Reputation: 120
  • View blog
  • Posts: 1,384
  • Joined: 14-January 10

Making a batch file to delete folders?

Posted 20 April 2010 - 08:23 PM

I've made a batch file that deletes everything inside of the temp folder. However, it deletes everything except the folders that are in the temp folder. Here is the code that I have right now:

del "C:\Documents and Settings\Administrator\Local Settings\Temp\*.*"

Any suggestions as to what I can do to make it so that my batch file will delete all the files and folders inside the temp folder.

Also is there anything I can do so that it doesn't just delete the files and folders inside the temp folder but also deletes the files and folders inside the temp folder on ALL other user accounts?

Thanks in advance for any help given.

Is This A Good Question/Topic? 0
  • +

Replies To: Making a batch file to delete folders?

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Making a batch file to delete folders?

Posted 20 April 2010 - 08:33 PM

the command to remove a directory is rmdir

or if you are really gutsy, you can do something like this :

cd "C:\Documents and Settings\Administrator\Local Settings\Temp"
del * /s /q


Was This Post Helpful? 0
  • +
  • -

#3 RandomlyKnighted   User is offline

  • D.I.C Lover
  • member icon

Reputation: 120
  • View blog
  • Posts: 1,384
  • Joined: 14-January 10

Re: Making a batch file to delete folders?

Posted 20 April 2010 - 08:51 PM

I know cd lets the batch file go to that particular folder but what does the * /s /q do? I tried looking it up and couldn't find much. Most of what I found on batch file commands just had simple stuff like rem, echo, del, etc. So if anyone knows of a good website with commands for batch file I'd really appreciate it. Also when I run the changes you made it still leaves the folders.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Making a batch file to delete folders?

Posted 20 April 2010 - 08:58 PM

I use a single asterisk because this will delete both all files & all directories. You can validate this by issuing dir * & you'll see only directories.

The switch s says to delete through all sub directories. So everything under the current directory will be trashed.

The switch q says to be quiet, otherwise you get prompted to confirm for each directory that it tries to delete.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1