Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am trying to get a batch file to delete folders and their contents. The batch file deletes all the files contained in the folders, BUT the folders still remain.

del /s /f /q C:\Users\GT\AppData\Roaming\uTorrent\CompletedDL\*.*
for /f %%f in ('dir /ad /b C:\Users\GT\AppData\Roaming\uTorrent\CompletedDL\') do rd /s /q
C:\Users\GT\AppData\Roaming\uTorrent\CompletedDL\%%f

can anyone see what the problem is?

3

1 Answer

I don't know what's not working in your script, but this should work:

del /f /q "%appdata%\uTorrent\CompletedDL\*.*"
for /d %%d in ("%appdata%\uTorrent\CompletedDL\*.*") do rmdir /s /q "%%d"

The /d switch searches for subdirectories which are then removed with rmdir. I also added double quotes, because rmdir would break if the path contains spaces.

The /s switch in the del command is not neccesary, because rmdir /s will remove files as well.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy