Delete files or folder recursively on windows cmd

How to delete files or folders recursively in Windows from the command line. I found this solution where the path we control the command line and run this command. I gave an example with the extension .svn.

for /r %R in (.svn) do if exist %R (rd /s /q "%R")

+69
windows cmd delete-file
Oct 05
source share
8 answers

Follow these steps:

  • Open command prompt
  • Change directory to desired path
  • Give the following command

    del /S *.svn

+74
09 Oct '14 at 2:09
source share

Other answers did not work for me, but this happened:

 del /s /q .svn rmdir /s /q .svn 

/ q disables the yes / no request

/ s means deleting file (s) from all subdirectories.

+46
Jul 11 '15 at 23:53 on
source share

You can use this in bat script:

 rd /s /q "c:\folder a" 

Now just change c:\folder to the location of your folder.

+20
05 Oct '12 at 15:37
source share
 RMDIR path_to_folder /S 

ex. RMDIR "C:\tmp" /S

Please note that you will be asked if you are really going to delete the "C: \ tmp" folder. Combining it with the / Q switch will delete the folder silently (for example RMDIR "C:\tmp" /S /Q )

+11
Jul 22 '14 at 5:19
source share

To delete the file, I wrote the following simple batch file that recursively deleted all .pdf files:

 del /s /q "\\ad1pfrtg001\AppDev\ResultLogs\*.pdf" del /s /q "\\ad1pfrtg001\Project\AppData\*.pdf" 

Even for a local directory, we can use it as:

 del /s /q "C:\Project\*.pdf" 

The same can be used to delete a directory where we just need to change del to rmdir .

+8
Jul 23 '15 at 19:44
source share

If you want to remove a specific extension recursively, use this:

 For /R "C:\Users\Desktop\saleh" %G IN (*.ppt) do del "%G" 
+3
Aug 28 '16 at 12:23
source share

You can also do:

 del /s /p *.{your extension here} 

/p offer you every found file if you are nervous because you don’t want to not do something.

+1
Jan 05 '17 at 18:07
source share

After this link https://blogs.technet.microsoft.com/heyscriptingguy/2006/10/23/how-can-i-use-windows-powershell-to-delete-all-the-tmp-files-on-a -drive / You can use something like this to delete all .tmp, for example, from a folder and all subfolders

get-childitem [your path / or leave empty for the current path] -include * .tmp -recurse | foreach ($ _) {remove-item $ _. fullname}

0
Nov 14 '17 at 20:50
source share



All Articles