PCbanter

PCbanter (http://www.pcbanter.net/index.php)
-   Windows 7 Forum (http://www.pcbanter.net/forumdisplay.php?f=48)
-   -   Delete many empty directories (http://www.pcbanter.net/showthread.php?t=1101449)

masonc August 29th 17 07:11 PM

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

Paul[_32_] August 29th 17 08:25 PM

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

Char Jackson August 29th 17 09:45 PM

Delete many empty directories
 
On Tue, 29 Aug 2017 11:11:35 -0700, masonc
wrote:

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


I've been using RED (Remove Empty Directories) for quite a few years and
haven't had any problems with it. It's freeware.

http://www.jonasjohn.de/red.htm


--

Char Jackson

Micky August 29th 17 10:03 PM

Delete many empty directories
 
In alt.windows7.general, on Tue, 29 Aug 2017 11:11:35 -0700, masonc
wrote:

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


If anything can do this easily, it's tcc/le , which is free. Nope. RD
doesn't have much more than DOS.

Then there is XXCopy, which I know for sure has commands regarding empty
directories, but I'd want to do some testing before letting it run wild.
Make a mistake and you delete who knows what else. (In the real world,
people have test environments, but most home users don't have one!). On
second thought, since Kan is so specific, I think moderate testing would
be enough. He also has a subcommand that will make a command run and
display messages but not actually do anything. I've never used it.
There's a mailing list.

XXCopy is in flux right now, because the owner died, until the son takes
over, but you can get a copy of the free version from me.

Here is what seems like the most relevant page from his help file:



Number : 3
Date : 2001-05-10
Author : Kan Yabumoto
Subject : How to remove empty directories
Size(KB) : 1
--------------------------------------------------------------------------------


Here's a trick to remove empty directories using XXCOPY.

XXCOPY \yourdir\ /RSY /S /X*

Explanation:

/RSY remove source directory (in this case \yourdir\)

== He is rarely confusing but here I think he is. IIUC yourdir would be
something like C:\ . He calls it the source directory because
everything related to xxcopy relates to copying source to target, and
the directory listed first is the source, but in this case there is no
target. (It doesn't mean source code or anything like that.)

/S including subdirectories
/X* exclude all files (* == same as *.* in Win32)

== better get /X* exactly right, because that's what keeps it from
deleting what you don't want deleted.

This technique takes advantage of the exclusion feature which
does not delete any existing file in the directory. Since
a subdirectory with a file (or subdirectory) won't be deleted,
the only subdirectories that are deleted are empty ones.
To make this command work better, you may want to add
the following switches

/H include hidden directories
/R handle read-only directories
/PD0 suppress prompt on directory
/Q2 quiet (no display on skipped files)

--------------------------------------

Incidentally, the following XXCOPY command line will do the opposite
(delete all files and leave directory skeleton behind)

XXCOPY \yourdir\ /RSY /S /ED /PD0

here,

/ED preserve an empty directory

Again, you may add /H /R /Q2 to make it more bullet-proof.

Kan Yabumoto


--------------------------------------------------------------------------------
This message if part of XXCOPY's message Archive.
The archive contains all the messages posted at Yahoo!Groups: XXCOPY.


Apparently when I wasn't looking Kan changed to using google search and
the site: subcommand to search his website. So you can find more in
google search with

empty site:http://www.xxcopy.com

For example here is the second hit, which discusses why this works.
http://www.xxcopy.com/xarc/msg/msg05313.htm

But basically it's a subset of his copy command, which has loads of
options including the option to not copy empty subdirectories in the
source and to delete them, so that the sourc matches the target. So why
do you need a target if your goal is to delete things in the source?
Well, you don't. And that is what is above.

He has logging too.


Kan had a great mind and I can't keep in my head even half of what this
program could do (And I can't imagine what the paid version could do
that the free version doesn't). So I would just work at getting it to
do specific things I wanted to do, put them in a bat file, and save
them. That's what I would do with this if I were you.

Zaidy036[_6_] August 30th 17 01:24 AM

Delete many empty directories
 
Paul wrote:
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


Look at https://blogs.msdn.microsoft.com/old...17-00/?p=22703

Also batch cmd For Files

--
Zaidy036

masonc August 30th 17 01:07 PM

Delete many empty directories
 
On Tue, 29 Aug 2017 11:11:35 -0700, masonc
wrote:

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


Thanks for the suggestions.

J. P. Gilliver (John)[_4_] August 30th 17 07:47 PM

Delete many empty directories
 
In message , Char Jackson
writes:
On Tue, 29 Aug 2017 11:11:35 -0700, masonc
wrote:

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


I've been using RED (Remove Empty Directories) for quite a few years and
haven't had any problems with it. It's freeware.

http://www.jonasjohn.de/red.htm


Not sure if it's quite what the OP wants - "batch" suggests he wants
automation - but I'd certainly second the endorsement of RED. Nicely
written, IMO (I mean the way it works; I haven't seen the source code!).
--
J. P. Gilliver. UMRA: 1960/1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf

"Address the chair!" "There isn't a chair, there's only a rock!" "Well, call
it a chair!" "Why not call it a rock?" (First series, fit the sixth.)

masonc August 31st 17 08:13 AM

Delete many empty directories
 
On Tue, 29 Aug 2017 15:45:57 -0500, Char Jackson
wrote:

On Tue, 29 Aug 2017 11:11:35 -0700, masonc
wrote:

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


I've been using RED (Remove Empty Directories) for quite a few years and
haven't had any problems with it. It's freeware.

http://www.jonasjohn.de/red.htm


Thanks for the RED suggestion. Seems to work wonders. Removed a
thousand empties. ---
However, I quickly hit "Exit" when it scanned 1193 empty among 30873
files in my *System plus Programs C:* Scared me.
Thanks again.

Stan Brown August 31st 17 11:29 AM

Delete many empty directories
 
On Tue, 29 Aug 2017 11:11:35 -0700, masonc wrote:

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


What does "doesn't work" mean? What error message do you get? Are
_any_ directories deleted, and if so what were their positions in the
tree? Etc.

You've been in this group long enough to know that it's not full of
psychics.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://BrownMath.com/
http://OakRoadSystems.com/
Shikata ga nai...

Char Jackson August 31st 17 03:53 PM

Delete many empty directories
 
On Thu, 31 Aug 2017 00:13:58 -0700, masonc
wrote:

On Tue, 29 Aug 2017 15:45:57 -0500, Char Jackson
wrote:

On Tue, 29 Aug 2017 11:11:35 -0700, masonc
wrote:

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


I've been using RED (Remove Empty Directories) for quite a few years and
haven't had any problems with it. It's freeware.

http://www.jonasjohn.de/red.htm


Thanks for the RED suggestion. Seems to work wonders. Removed a
thousand empties. ---
However, I quickly hit "Exit" when it scanned 1193 empty among 30873
files in my *System plus Programs C:* Scared me.
Thanks again.


I've never used it from the root of a drive, so that's probably scary.
It's a handy little program. I'm glad you like it.

--

Char Jackson

Diesel September 2nd 17 05:42 AM

Delete many empty directories
 
Char Jackson
Tue, 29 Aug 2017
20:45:57 GMT in alt.windows7.general, wrote:

On Tue, 29 Aug 2017 11:11:35 -0700, masonc
wrote:

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


I've been using RED (Remove Empty Directories) for quite a few
years and haven't had any problems with it. It's freeware.

http://www.jonasjohn.de/red.htm



I snagged the portable version. Many thanks!


--
https://tekrider.net/pages/david-brooks-stalker.php
http://picpaste.com/B4rjEFK0.jpg - David and Trisha
http://picpaste.com/U5np7XvN.jpg - RIAA love David style
http://picpaste.com/rjIb8Mht.jpg - David And Trisha introducing Nick!
http://bughunter.it-mate.co.uk/bdemail1.zip - The *STALKING* begins.

One workman asks another, "How long have you been working here?"
The other one replies, "Since they threatened to fire me."


All times are GMT +1. The time now is 02:43 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2004 - 2006 PCbanter
Comments are property of their posters