Link to home
Create AccountLog in
Avatar of bsharath
bsharathFlag for India

asked on

Delete all folders that does not have files any files within the folder.

Hi,

Delete all folders that does not have files any files within the folder.
In a specific folder i need to do this.

Regards
Sharath
ASKER CERTIFIED SOLUTION
Avatar of zoofan
zoofan
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Paolo Santiangeli
Hi,
single batch command found on internet:
for /f "usebackq" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d"

Open in new window

Avatar of bsharath

ASKER

Thank U
glad to help,

zf
Zoofan the script worked perfect in the morning. When i try now i get this

---------------------------
Windows Script Host
---------------------------
Script:      D:\Delete.vbs
Line:      39
Char:      9
Error:      Path not found
Code:      800A004C
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------

Same script... :-(
Zoofan the script worked perfect in the morning. When i try now i get this

---------------------------
Windows Script Host
---------------------------
Script:      D:\Delete.vbs
Line:      39
Char:      9
Error:      Path not found
Code:      800A004C
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------

Same script... :-(
Make sure the list of folders to create are in paths that exist.

IE you can not do this
one
one\new1
two
two\new1
three\new1  <--this will error as three hasnt been made yet.
three



zf
zoofan is int this post for deleting all empty folders?