<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx</link><description>Don't need a whole program.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403096</link><pubDate>Thu, 17 Apr 2008 17:15:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403096</guid><dc:creator>SRS</dc:creator><description>&lt;p&gt;I like the advice that goes with Empty Folder Nuker v1.2.0 as well: &amp;quot;Now of course you should be careful not to delete important files - that much should be a given&amp;quot;. Wise words indeed.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403146</link><pubDate>Thu, 17 Apr 2008 17:28:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403146</guid><dc:creator>Danielw</dc:creator><description>&lt;p&gt;Just don't run that if you're a purist like me and have no desktop icons. &amp;nbsp;Windows kinda goes nuts. &amp;nbsp;At least it did the last time I tried to run it.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403164</link><pubDate>Thu, 17 Apr 2008 17:34:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403164</guid><dc:creator>Karellen</dc:creator><description>&lt;p&gt;I can't figure out from the linked page whether or not the program also deletes empty files first. The guy seems completely confused about the distinction between files and folders, making it unclear what the program does.&lt;/p&gt;
&lt;p&gt;It's entirely possible to conclude from what he's written that he considers a folder that contains files, all of which are 0 bytes in length, as being empty. In which case the program might delete all empty files (0 bytes in length) first and then delete any folders that are empty, including folders that have just been emptied by removing 0-byte files.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403236</link><pubDate>Thu, 17 Apr 2008 17:48:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403236</guid><dc:creator>Rajesh</dc:creator><description>&lt;p&gt;This script fails if the directory name containes any space(blank) charecters.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403263</link><pubDate>Thu, 17 Apr 2008 17:54:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403263</guid><dc:creator>John</dc:creator><description>&lt;p&gt;I would rather gauge my eyes out, thank you very much.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403264</link><pubDate>Thu, 17 Apr 2008 17:55:08 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403264</guid><dc:creator>ak</dc:creator><description>&lt;p&gt;I made a program that does this awell, I'm sure you could do it in a batch file, but it needs more handling than you have here. &lt;/p&gt;
&lt;p&gt;On win9x, there are a couple of folders that can be empty, but you don't want to delete them because it messes up the shell (IIRC the desktop and all users desktop folders) &lt;/p&gt;
&lt;p&gt;Also, you don't want to delete empty guid folders (Don't know the proper name for those) ex: &amp;quot;Control Panel.{control_panel_guid}&amp;quot;&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403524</link><pubDate>Thu, 17 Apr 2008 18:52:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403524</guid><dc:creator>John Vert</dc:creator><description>&lt;p&gt;To fix the problem with spaces in paths, use the delims option:&lt;/p&gt;
&lt;p&gt; &amp;nbsp;for /f &amp;quot;usebackq delims=&amp;quot; %%d in (`&amp;quot;dir /ad/b/s | sort /R&amp;quot;`) do rd &amp;quot;%%d&amp;quot;&lt;/p&gt;
&lt;p&gt;Then it will not tokenize the line.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403556</link><pubDate>Thu, 17 Apr 2008 18:59:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403556</guid><dc:creator>Tom</dc:creator><description>&lt;p&gt;Actually, I really do enjoy working with batch files. &amp;nbsp;Some of my earliest programming was writing .bat files for DOS (who can forget autoexec.bat?). &amp;nbsp;Things have gotten much more sophisticated as Windows has added features to the language, and yet it retains its simple and familiar feel. &amp;nbsp;It has a certain charm and accessibility which I find completely absent in other shells and scripting environments.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403567</link><pubDate>Thu, 17 Apr 2008 19:02:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403567</guid><dc:creator>Franci Penov</dc:creator><description>&lt;p&gt;Or you could just do rd /s /q /f &amp;quot;&amp;lt;empty folder&amp;gt;&amp;quot;. Saves you additional 60 chars. :-)&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403637</link><pubDate>Thu, 17 Apr 2008 19:20:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403637</guid><dc:creator>KJK::Hyperion</dc:creator><description>&lt;p&gt;or, losing the heinous &amp;quot;usebackq&amp;quot; option:&lt;/p&gt;
&lt;p&gt;for /f &amp;quot;tokens=*&amp;quot; %%d in ('dir /ad/b/s ^| sort /R') do rd &amp;quot;%%d&amp;quot;&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403638</link><pubDate>Thu, 17 Apr 2008 19:22:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403638</guid><dc:creator>KJK::Hyperion</dc:creator><description>&lt;p&gt;Franci: don't even JOKE. rd /s deletes all subfolders AND files&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403672</link><pubDate>Thu, 17 Apr 2008 19:31:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403672</guid><dc:creator>anonymous</dc:creator><description>&lt;p&gt;Why the unnecessary usebackq? To use the quotes, because yor don't know how to escape the pipe symbol? Or what? It can be so simple:&lt;/p&gt;
&lt;p&gt;for /f &amp;quot;delims=&amp;quot; %%i in ('dir /s /b /ad ^| sort /r') do rd &amp;quot;%%i&amp;quot;&amp;gt;NUL&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403694</link><pubDate>Thu, 17 Apr 2008 19:37:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403694</guid><dc:creator>Fenster</dc:creator><description>&lt;p&gt;When I want to delete all folders (not necessarily empty ones). &amp;nbsp;I use robocopy using /MIR option and set the source folder as an empty folder and the destination as the folders I want to delete e.g:&lt;/p&gt;
&lt;p&gt;SET SOURCE=N:\TempDir&lt;/p&gt;
&lt;p&gt;SET DEST=N:\Trash&lt;/p&gt;
&lt;p&gt;MD %SOURCE%&lt;/p&gt;
&lt;p&gt;ROBOCOPY %SOURCE% %DEST% /MIR /R:01 /W:01 &lt;/p&gt;
&lt;p&gt;del %SOURCE%&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403695</link><pubDate>Thu, 17 Apr 2008 19:37:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403695</guid><dc:creator>Mega Bloat</dc:creator><description>&lt;p&gt;cmd.exe is 382 kb (winxp). What kind of bloatware is this?&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403733</link><pubDate>Thu, 17 Apr 2008 19:48:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403733</guid><dc:creator>anon</dc:creator><description>&lt;p&gt;Can somebody please provide a dummy's explanation of what usebackq is used for and how it's better than tokens?&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403814</link><pubDate>Thu, 17 Apr 2008 20:07:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403814</guid><dc:creator>tkeane</dc:creator><description>&lt;p&gt;@anon-&lt;/p&gt;
&lt;p&gt;I've heard there are magical web-sites where you can type in words such as 'usebackq' and 'tokens' and get links to relevant articles about them...&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403836</link><pubDate>Thu, 17 Apr 2008 20:11:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403836</guid><dc:creator>Josh</dc:creator><description>&lt;p&gt;@anon:&lt;/p&gt;
&lt;p&gt;It's got nothing to do with tokenizing. &amp;nbsp;usebackq simply makes the command in the parentheses be delimited with backquotes, ` (it's right above the Tab on most QWERTYs), instead of normal quotes, ', &amp;nbsp;which allows for you to use a number of symbols in the command string directly which would otherwise have to be escaped.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8403936</link><pubDate>Thu, 17 Apr 2008 20:36:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8403936</guid><dc:creator>anon</dc:creator><description>&lt;p&gt;@Josh:&lt;/p&gt;
&lt;p&gt;Thanks. &amp;nbsp;Exactly what I was looking for.&lt;/p&gt;
&lt;p&gt;@tkeane:&lt;/p&gt;
&lt;p&gt;That type of comment doesn't help anyone. &amp;nbsp;The first page of results from &lt;a rel="nofollow" target="_new" href="http://www.google.com/search?q=usebackq"&gt;http://www.google.com/search?q=usebackq&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;Has 3 explanations that are identical, 3 that require you to login to a site and the rest are useless.&lt;/p&gt;
&lt;p&gt;Thanks to Josh there will now be one more explanation on the first page when people go to these magical web sites.&lt;/p&gt;
&lt;p&gt;Is it really so bad to ask for an alternate explanation?&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8404497</link><pubDate>Thu, 17 Apr 2008 23:17:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8404497</guid><dc:creator>Cooney</dc:creator><description>&lt;p&gt;this is all too complicated. Install some unix tools and do this:&lt;/p&gt;
&lt;p&gt;find &amp;lt;dir&amp;gt; -depth -type d -empty|xargs rmdir&lt;/p&gt;
&lt;p&gt;as a bonus, if I screwed up the command, rmdir fails when the dir isn't empty.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8404555</link><pubDate>Thu, 17 Apr 2008 23:35:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8404555</guid><dc:creator>oskopia</dc:creator><description>&lt;p&gt;I work with batch files - not often, but if I need something, they can do. But I have heard, Basic ... some sort of Basic is much better for it. Unfortunately I am not used to it, but to batch files.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8404842</link><pubDate>Fri, 18 Apr 2008 00:59:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8404842</guid><dc:creator>njkayaker</dc:creator><description>&lt;p&gt;@anon: &amp;quot;That type of comment doesn't help anyone.&amp;quot;&lt;/p&gt;
&lt;p&gt;Your original post is indistiguishable from what some one too lazy to to a web search would have posted. (Hint: provide some evidence that you've performed the search before asking the question.)&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8404921</link><pubDate>Fri, 18 Apr 2008 01:18:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8404921</guid><dc:creator>anonymous</dc:creator><description>&lt;p&gt;@Josh: Adding the usebackq and trying to find the horribly stupid backquotes on an EN-US keyboard (hint: not there, you have to use AltGr+XXXX) is definitely much less efficient than simply escaping one or too ampersands or pipes.&lt;/p&gt;
&lt;p&gt;@anon: tokens=* instead of delims= is just less understandable and non-obvious.&lt;/p&gt;
&lt;p&gt;And for the usebackq: Where's your problem with typing &amp;quot;for /?&amp;quot; on your command prompt?&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8404950</link><pubDate>Fri, 18 Apr 2008 01:26:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8404950</guid><dc:creator>Neil</dc:creator><description>&lt;p&gt;Using the -empty primary for find doesn't work, because as Raymond says, &amp;quot;we enumerate the directories bottom-up rather than top-down. This is important for deleting empty directories because you have to remove the subdirectories before you remove the parent.&amp;quot; Therefore you have to find all subdirectories and rely on rmdir only removing the empty ones.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8405025</link><pubDate>Fri, 18 Apr 2008 01:48:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8405025</guid><dc:creator>Mike Heath</dc:creator><description>&lt;P&gt;It's blog posts like this that make me glad I have Cygwin. &amp;nbsp;It's a simple rm -rf dirname.&lt;/P&gt;
&lt;DIV class=post&gt;[&lt;I&gt;Um, that removes nonempty directories too. -Raymond&lt;/I&gt;]&lt;/DIV&gt;</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8405029</link><pubDate>Fri, 18 Apr 2008 01:50:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8405029</guid><dc:creator>Cooney</dc:creator><description>&lt;p&gt;&amp;gt; Using the -empty primary for find doesn't work, because as Raymond says, &amp;quot;we enumerate the directories bottom-up rather than top-down.&lt;/p&gt;
&lt;p&gt;that's what -depth is for - it enumerates bottom up.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8405378</link><pubDate>Fri, 18 Apr 2008 03:19:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8405378</guid><dc:creator>chrismcb</dc:creator><description>&lt;p&gt;@cooney&lt;/p&gt;
&lt;p&gt;How is &amp;quot;find &amp;lt;dir&amp;gt; -depth -type d -empty|xargs rmdir&amp;quot; any less complicated?&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8405552</link><pubDate>Fri, 18 Apr 2008 04:01:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8405552</guid><dc:creator>steveg</dc:creator><description>&lt;p&gt;usebackq: &lt;a rel="nofollow" target="_new" href="http://www.ss64.com/nt/for_cmd.html"&gt;http://www.ss64.com/nt/for_cmd.html&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8405903</link><pubDate>Fri, 18 Apr 2008 05:56:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8405903</guid><dc:creator>Jeff Tyrrill</dc:creator><description>&lt;p&gt;Once again, we encounter the main reason that the command line is ill-equipped for any serious task: This script does not work with non-ASCII (such as Japanese) characters. Tested on Vista.&lt;/p&gt;
&lt;p&gt;I note that the linked program does support Unicode (even though it had to be &amp;quot;added&amp;quot; after the first release).&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8406328</link><pubDate>Fri, 18 Apr 2008 07:37:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8406328</guid><dc:creator>MadQ</dc:creator><description>&lt;p&gt;Jeff: Out of curiousity, have you tried changing the console's code page? For example, to set the code page to UTF-8: MODE CON CP /SELECT=65001&lt;/p&gt;
&lt;p&gt;Or maybe 932 (ANSI/OEM Japanese; Japanese (Shift-JIS)) or one of the other japanese code pages would work. I'm just stabbing in the dark; I know nothing about Japanese.&lt;/p&gt;
</description></item><item><title>Cancellare le cartelle orfane con una sola riga di comando | Il blog che non c'??</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8407285</link><pubDate>Fri, 18 Apr 2008 12:59:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8407285</guid><dc:creator>Cancellare le cartelle orfane con una sola riga di comando | Il blog che non c'??</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.gialloporpora.netsons.org/index.php/2008/04/18/cancellare-le-cartelle-orfane-con-una-sola-riga-di-comando/"&gt;http://www.gialloporpora.netsons.org/index.php/2008/04/18/cancellare-le-cartelle-orfane-con-una-sola-riga-di-comando/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8407739</link><pubDate>Fri, 18 Apr 2008 15:12:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8407739</guid><dc:creator>BryanK</dc:creator><description>&lt;p&gt;Eeew, piping to xargs!&lt;/p&gt;
&lt;p&gt;On Unix, any byte is valid in a file or directory name except the zero byte and the byte used for the ASCII forward slash character (0x2f). &amp;nbsp;Piping to xargs fails if any directory anywhere in the output of find has a newline in its name.&lt;/p&gt;
&lt;p&gt;What does work is:&lt;/p&gt;
&lt;p&gt;find -depth -type d -empty -exec rmdir {} \;&lt;/p&gt;
&lt;p&gt;to have find execute rmdir directly.&lt;/p&gt;
&lt;p&gt;(Of course all this requires some sort of Unix find to be installed, which means it's a bad solution for Windows. &amp;nbsp;It also breaks as soon as you need to run it on some machine that you don't own...)&lt;/p&gt;
</description></item><item><title>Enjoying batch files</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8407770</link><pubDate>Fri, 18 Apr 2008 15:28:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8407770</guid><dc:creator>Gerald</dc:creator><description>&lt;p&gt;Actually, these postings are the ones I love the most.&lt;/p&gt;
&lt;p&gt;I doubt I'll ever have to program scrollbar behaviors, but this kind of stuff is extremely useful. It doesn't just show a specific solution to a specific problem, but also introduces a line of thinking which makes me consider &amp;quot;oh, I could actually use this for something else...&amp;quot;&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8408061</link><pubDate>Fri, 18 Apr 2008 18:30:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408061</guid><dc:creator>anonymous</dc:creator><description>&lt;p&gt;Jeff and MadQ, did you ever consider &amp;quot;cmd /u&amp;quot;?&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8408292</link><pubDate>Fri, 18 Apr 2008 19:35:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408292</guid><dc:creator>Yuliy</dc:creator><description>&lt;p&gt;@chrismcb&lt;/p&gt;
&lt;p&gt;It's different because it fails to delete a directory which has only an empty directory as a subdirectory. Raymond's solution tries to rd every directory. It succeeds for empty directories (when it gets to them) but fails for those that are empty.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8408329</link><pubDate>Fri, 18 Apr 2008 19:46:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408329</guid><dc:creator>Adam</dc:creator><description>&lt;p&gt;@Cooney and BryanK&lt;/p&gt;
&lt;p&gt;Even simpler Unix one-liners that don't require piping or spawning new processes:&lt;/p&gt;
&lt;p&gt;To delete 0-byte files and empty directories:&lt;/p&gt;
&lt;p&gt;find &amp;lt;dir&amp;gt; -empty -delete&lt;/p&gt;
&lt;p&gt;To delete empty directories but not 0-byte files:&lt;/p&gt;
&lt;p&gt;find &amp;lt;dir&amp;gt; -empty -type d -delete&lt;/p&gt;
&lt;p&gt;Note that the -delete option implies -depth.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8408410</link><pubDate>Fri, 18 Apr 2008 20:08:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408410</guid><dc:creator>Anonymous Coward</dc:creator><description>&lt;p&gt;&amp;quot;Where's your problem with typing &amp;quot;for /?&amp;quot; on your command prompt?&amp;quot;&lt;/p&gt;
&lt;p&gt;Some of us don't use Windows but still enjoy Raymond's informative and insightful posts.&lt;/p&gt;
&lt;p&gt;Typing &amp;quot;for /?&amp;quot; on a Bourne shell won't do any good.&lt;/p&gt;
&lt;p&gt;(Of course, one could try running Wine's cmd.exe and typing &amp;quot;for /?&amp;quot; there... Assuming they implemented the help parts of cmd.exe, that they implemented the &amp;quot;advanced&amp;quot; functions of cmd.exe, that they didn't make any mistake on the help text, and that you are running on a i386-derived platform.)&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8408426</link><pubDate>Fri, 18 Apr 2008 20:12:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408426</guid><dc:creator>BryanK</dc:creator><description>&lt;p&gt;-delete? &amp;nbsp;Wow, I had no idea that existed... &amp;nbsp;Thanks! &amp;nbsp;:-)&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8408736</link><pubDate>Fri, 18 Apr 2008 21:43:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8408736</guid><dc:creator>Jay Bazuzi</dc:creator><description>&lt;p&gt;I was a CMD scripting nut for many years, but thanks to PowerShell, I can cut off the oxygen supply to that part of my brain.&lt;/p&gt;
&lt;p&gt;One thing that most of the alternative solutions proposed here seem to miss is that if a directory contains no files in any of its subdirectories, Raymond's one-liner will delete them. &amp;nbsp;My proposal fails that test, too, I'm afraid, but I offer it here anyway as an example of the wonder of PowerShell.&lt;/p&gt;
&lt;p&gt;Get-ChildItem -Recurse . | where { $_.PSISContainer -and @( $_ | Get-ChildItem ).Count -eq 0 } | Remove-Item&lt;/p&gt;
&lt;p&gt;or, more tersely,&lt;/p&gt;
&lt;p&gt;gci -R . | where { $_.PSISContainer -and @( $_ | gci ).Count -eq 0 } | ri&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8409289</link><pubDate>Sat, 19 Apr 2008 01:48:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8409289</guid><dc:creator>Neil</dc:creator><description>&lt;p&gt;&amp;gt;One thing that most of the alternative solutions proposed here seem to miss is that if a directory contains no files in any of its subdirectories, Raymond's one-liner will delete them.&lt;/p&gt;
&lt;p&gt;And they continued to do so after I quoted Raymond, which just goes to show that nobody actually reads anything he writes. (Now, where was that article on write-only memory?)&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8409809</link><pubDate>Sat, 19 Apr 2008 08:08:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8409809</guid><dc:creator>GreaseMonkey</dc:creator><description>&lt;p&gt;&amp;gt; cmd.exe is 382 kb (winxp). What kind of bloatware is this?&lt;/p&gt;
&lt;p&gt;It does more than just delete files.&lt;/p&gt;
&lt;p&gt;By the way, /bin/bash is 661KB. If you're typing that on a mac, I could probably guarantee it's more bloated than cmd.exe. /bin/busybox is 440KB or something, and it's got a lot of stuff; I'm unsure if it matches cmd.exe though.&lt;/p&gt;
&lt;p&gt;In honour of Linux bloatware though... /bin/true and /bin/false are 11KB here; I can make a file in DEBUG.EXE to do the same thing, and that takes up only 5 bytes. With an MZ header (DOS EXE), I could probably do that in 37 bytes. Although, someone made a Linux ELF program in a very similar vein which was only 46 bytes, even though it walked all over the header. The smallest PE file (Windows EXE) is about 81 bytes or something, and it doesn't work on 2000/XP due to the lack of headers.&lt;/p&gt;
&lt;p&gt;As for the deletion script, I haven't worked out how to do the same in a bourne shell, but it'd be a lot better than 260KB. Heck, I could do a C program better than that, maybe even a C++ one or a Java one using GCJ.&lt;/p&gt;
&lt;p&gt;So yeah, goes both ways.&lt;/p&gt;
</description></item><item><title>.neteffect, April 20, 2008 | BlogWell</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8412796</link><pubDate>Sun, 20 Apr 2008 23:09:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8412796</guid><dc:creator>.neteffect, April 20, 2008 | BlogWell</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blog-well.com/2008/04/20/neteffect-april-20-2008/"&gt;http://blog-well.com/2008/04/20/neteffect-april-20-2008/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8413642</link><pubDate>Mon, 21 Apr 2008 06:52:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8413642</guid><dc:creator>Jonathan Camacho</dc:creator><description>&lt;p&gt;@BryanK&lt;/p&gt;
&lt;p&gt;The -print0 / --null option can be used to let xargs function when the input filenames contain whitespace.&lt;/p&gt;
&lt;p&gt;find -depth -type d -empty -print0 | xargs --null rmdir &lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8415172</link><pubDate>Mon, 21 Apr 2008 21:49:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8415172</guid><dc:creator>Ben Voigt</dc:creator><description>&lt;p&gt;@Camacho&lt;/p&gt;
&lt;p&gt;That still collects all the names first, which:&lt;/p&gt;
&lt;p&gt;(1) Doesn't delete directories that are recursively empty.&lt;/p&gt;
&lt;p&gt;(2) Risks exceeding the maximum command-line length.&lt;/p&gt;
&lt;p&gt;Better options have already been given.&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8415284</link><pubDate>Mon, 21 Apr 2008 22:53:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8415284</guid><dc:creator>David Walker</dc:creator><description>&lt;p&gt;@Clooney: Now you have two problems. &amp;nbsp;(It seems like I have heard that somewhere before...)&lt;/p&gt;
</description></item><item><title>re: One-line batch script to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8416832</link><pubDate>Tue, 22 Apr 2008 19:38:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8416832</guid><dc:creator>Rick</dc:creator><description>&lt;p&gt;Jesus Christ Ray every time you post its like planting a seed, branches grow off in all kinds of crazy directions. &lt;/p&gt;
&lt;p&gt;Thanks for posting the oneliner, I've been trying to figure that one out for some time. I had not thought of relying on rd's inability to remove non-empty folders.&lt;/p&gt;
</description></item><item><title>conormulligan.com / blog  &amp;raquo; One-line batch file to delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8417189</link><pubDate>Tue, 22 Apr 2008 23:35:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8417189</guid><dc:creator>conormulligan.com / blog  &amp;raquo; One-line batch file to delete empty directories</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://conormulligan.com/blog/2008/04/22/one-line-batch-file-to-delete-empty-directories/"&gt;http://conormulligan.com/blog/2008/04/22/one-line-batch-file-to-delete-empty-directories/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>links for 2008-05-06 &amp;laquo; LAN b4 Time</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8461794</link><pubDate>Tue, 06 May 2008 03:33:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8461794</guid><dc:creator>links for 2008-05-06 &amp;laquo; LAN b4 Time</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://cdavis1962.wordpress.com/2008/05/06/links-for-2008-05-06/"&gt;http://cdavis1962.wordpress.com/2008/05/06/links-for-2008-05-06/&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>The Industry Standard's Top 25 B-to-Z List Blogs</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8509043</link><pubDate>Thu, 15 May 2008 22:52:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8509043</guid><dc:creator>TrackBack</dc:creator><description>&lt;br&gt;</description></item><item><title>Recursively delete empty directories</title><link>http://blogs.msdn.com/oldnewthing/archive/2008/04/17/8399914.aspx#8716636</link><pubDate>Thu, 10 Jul 2008 15:15:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8716636</guid><dc:creator>Being Cellfish</dc:creator><description>&lt;p&gt;I recently had to find a neat way to remove all empty directories recursively on a Unix machine. In the&lt;/p&gt;
</description></item></channel></rss>