View Single Post
  #2  
Old August 29th 17, 08:25 PM posted to alt.windows7.general
Paul[_32_]
external usenet poster
 
Posts: 11,873
Default Delete many empty directories

masonc wrote:
Is there any way to batch delete many empty sub-directories?
(RD empties* doesn't work)


Is there a permissions problem ?

You could list all the directories and
make a script with one "rd" per line if you want.

Or I'm sure someone gifted at writing such scripts
could write you one :-)

If your attempts to remove are causing a dialog box to
pop up for some reason, then that would be a valid reason
for a wild card attempt to not work.

*******

If you do:

rd /?

it offers /s for recursive, and /q for quiet mode.
Maybe the quiet mode will provide sufficient suppression
for the wild-card call to work ?

*******

There are articles for this, too.

https://stackoverflow.com/questions/...command-prompt

You will notice there is a clever robocopy command,
which removes all empty folders below folder1. Now
this is neat and tidy... but needs to be tested
on an inert folder tree first. You want to carefully
test this doesn't have unexpected side effects.

ROBOCOPY folder1 folder1 /S /MOVE

A folder might not be considered empty, if it has
a desktop.ini file in it. There might be a reason
for mis-behavior in some cases. In File Explorer,
there is a Tools:View option to make "system" files
visible, and then the desktop.ini files can be seen.
It's both a feature and a nuisance, that option
(as it can cause a couple desktop.ini files to appear
on your actual desktop).

Paul
Ads