<?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>Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx</link><description>I recently had to find a neat way to remove all empty directories recursively on a Unix machine. In the world of UNIX you can expect to find a way to do things like this pretty easy. When I started to search for a neat way to do it (rather than reading</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9576405</link><pubDate>Wed, 29 Apr 2009 23:10:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9576405</guid><dc:creator>Emil Gustafsson</dc:creator><description>&lt;p&gt;Good point! I've added double quotes in the original post now.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9576405" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9575881</link><pubDate>Wed, 29 Apr 2009 18:03:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9575881</guid><dc:creator>Cristian Vidmar</dc:creator><description>&lt;p&gt;cellfish, your script saved my day but I suggest putting double quotes around $D otherwise the script will fail on directory names with spaces&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9575881" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9421107</link><pubDate>Sat, 14 Feb 2009 10:28:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9421107</guid><dc:creator>Emil Gustafsson</dc:creator><description>&lt;p&gt;@cLive:&lt;/p&gt;
&lt;p&gt;fair enough but still all the options used are not available on all platforms.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9421107" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9420726</link><pubDate>Sat, 14 Feb 2009 05:54:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9420726</guid><dc:creator>cLive ;-)</dc:creator><description>&lt;p&gt;@cellfish - no, ZungBang is correct - look up what the &amp;quot;-depth&amp;quot; option does to the recursion order.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9420726" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9375101</link><pubDate>Sun, 25 Jan 2009 20:21:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9375101</guid><dc:creator>Emil Gustafsson</dc:creator><description>&lt;p&gt;@Magnus:&lt;/p&gt;
&lt;p&gt;Nice since it does not print any error messages for non empty directories. However it assumes perl is installed which might not always be the case.&lt;/p&gt;
&lt;p&gt;Just in case the link disapears, here's the perl command: perl -MFile::Find -e&amp;quot;finddepth(sub{rmdir},'.')&amp;quot;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9375101" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9375075</link><pubDate>Sun, 25 Jan 2009 19:46:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9375075</guid><dc:creator>Magnus</dc:creator><description>&lt;p&gt;Here's a nice Perl one-liner:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://duramecho.com/ComputerPrograms/DeleteEmptyDirectories/index.html"&gt;http://duramecho.com/ComputerPrograms/DeleteEmptyDirectories/index.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9375075" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9031809</link><pubDate>Mon, 03 Nov 2008 10:48:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9031809</guid><dc:creator>Emil Gustafsson</dc:creator><description>&lt;p&gt;@ZungBang:&lt;/p&gt;
&lt;p&gt;Your example does not know because if I have a structure &amp;quot;A/B&amp;quot; where the folder B is the only content of A your example will only delete B. Also the -empty option is not available on all platforms, for example the standard find on Solaris 8 does not support -empty. Nor does the rmdir on Solaris 8 support &amp;quot;--ignore-fail-on-non-empty&amp;quot; which could be used to supress error messages (instead of piping to /dev/null) from rmdir.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9031809" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#9029019</link><pubDate>Sun, 02 Nov 2008 12:03:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9029019</guid><dc:creator>ZungBang</dc:creator><description>&lt;p&gt;find &amp;lt;parent-dir&amp;gt; -depth -type d -empty -exec rmdir -v {} \;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9029019" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#8722879</link><pubDate>Sat, 12 Jul 2008 09:49:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8722879</guid><dc:creator>Emil Gustafsson</dc:creator><description>&lt;p&gt;Actually the &amp;quot;ls | grep&amp;quot; part is some kind of premature optimization (which got in there since it was in the example I looked at). That is why I pipe the output to /dev/null since I don't want to see the messages about directories not being removed since it is non-empty. Consider the structure &amp;quot;a/b/file&amp;quot;. The script above will try to remove &amp;quot;a&amp;quot; (since it contains no files) and fails since &amp;quot;b&amp;quot; is still there.&lt;/p&gt;
&lt;p&gt;A cleaner solution would have only &amp;quot;rmdir $D 2&amp;gt;/dev/null&amp;quot;. All this assumes that you have not changed rmdir to an alias like &amp;quot;rm -rf&amp;quot; ofcouse...&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8722879" width="1" height="1"&gt;</description></item><item><title>re: Recursively delete empty directories</title><link>http://blogs.msdn.com/b/cellfish/archive/2008/07/10/recursively-delete-empty-directories.aspx#8717150</link><pubDate>Thu, 10 Jul 2008 17:39:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8717150</guid><dc:creator>Raymond Chen - MSFT</dc:creator><description>&lt;p&gt;What if the directory is nonempty but contains only hidden files? Should that be an &amp;quot;ls -la&amp;quot; / total 2?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8717150" width="1" height="1"&gt;</description></item></channel></rss>