views:

684

answers:

2

Hello,

Can someone help me with something I want to achieve in CMD?

Say, there is a variable called %pathtofolder%, and, as it makes clear; it is a full path to a folder.

Now, what i want to do is, to delete every single file and subfolder in this directory. But not the directory itself.

But, there might be an error like 'this file/folder is already in use'... when that happens, it should just continue and skip that file/folder.

Can anyone give me some code for this? Thanks in advance.

+4  A: 
del %pathtofolder%\*.*   /s /f  /q

delete all files and subfolders in %pathtofolder% , including read-only files, do not prompt for confirmation

Alon
Thanks! This works fine.
YourComputerHelpZ
A: 

I am also using this, cleans up the folder temp folders that are created

FOR /D %%p IN ("C:\Temp\*.*") DO rmdir "%%p" /s /q
Iain