Reputation: 13
my problem is that we have a network share with different subfolders with ACL permissions etc.
I need to keep the 1st level but also need to delete everything in these folders.
share:\Test1\Test11\...
share:\Test1\Test12\...
share:\Test2\Test21\...
share:\Test2\Test22\...
share:\Test3\Test31\...
share:\Test3\Test32\...
share:\Test...
The result hast to be:
share:\Test1\
share:\Test2\
share:\Test3\
share:\Test...
I found solutions with one root folder but I have multiple with different names, not all is testxxx.
Any help is appreciated. Thank you.
Upvotes: 1
Views: 65
Reputation:
RD /S /Q . 2>NUL
this will erase all files and folders and try to erase the current folder what will fail thus requirung error output redirection to NUL @Echo off
Pushd "share:\"
For /F "delims=" %%A in ('dir /B/AD') Do (
Pushd "%%~A"
RD /S /Q . 2>NUL
PopD
)
PopD
Upvotes: 1