Reputation: 15
I have on my computer an partition named H: On that partition i have diffent folders with each a folder called "bin" Example:
H:MyFolder\Bin
H:AnotherFolder\Bin
I know that I can delete bin with the follow command:
set folder="H:\Bin"
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
Is it possible to empty all the bin folders from all folders in partition H: with a command?
Upvotes: 1
Views: 654
Reputation: 70923
This will remove the content of all the bin
folders under H:\
while keeping the folders.
for /r "H:\" /d %%a in (bin) do @if exist "%%~fa\" ( pushd "%%~fa" && ( echo "%%~fa" & echo rmdir . /s /q & popd ))
There is an echo
command that precedes the rmdir
. This is included for testing and must be removed to perform the content removal.
Upvotes: 2