<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Delete_directory_with_exclusion</id>
	<title>Delete directory with exclusion - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Delete_directory_with_exclusion"/>
	<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Delete_directory_with_exclusion&amp;action=history"/>
	<updated>2026-04-22T18:01:45Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=Delete_directory_with_exclusion&amp;diff=16518&amp;oldid=prev</id>
		<title>BAPBAP: User talk:BAPBAP moved to Delete directory with exclusion: Incorrect title</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Delete_directory_with_exclusion&amp;diff=16518&amp;oldid=prev"/>
		<updated>2008-12-20T22:20:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/User_talk:BAPBAP&quot; class=&quot;mw-redirect&quot; title=&quot;User talk:BAPBAP&quot;&gt;User talk:BAPBAP&lt;/a&gt; moved to &lt;a href=&quot;/Delete_directory_with_exclusion&quot; title=&quot;Delete directory with exclusion&quot;&gt;Delete directory with exclusion&lt;/a&gt;: Incorrect title&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;â† Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:20, 20 December 2008&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key n22049_wiki-wiki_:diff::1.12:old-16517:rev-16518 --&gt;
&lt;/table&gt;</summary>
		<author><name>BAPBAP</name></author>
	</entry>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=Delete_directory_with_exclusion&amp;diff=16517&amp;oldid=prev</id>
		<title>BAPBAP: Delete directory with exclusion</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=Delete_directory_with_exclusion&amp;diff=16517&amp;oldid=prev"/>
		<updated>2008-12-20T22:14:26Z</updated>

		<summary type="html">&lt;p&gt;Delete directory with exclusion&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{PageAuthor|BAPBAP}}&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
These macros allow you to remove all directories except you define.&lt;br /&gt;
&lt;br /&gt;
Provided &amp;quot;as is&amp;quot; by [BAPBAP].&lt;br /&gt;
Use on your own risk. &lt;br /&gt;
&lt;br /&gt;
== The Script ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
Function DeleteFoldersWithExclusion&lt;br /&gt;
 Exch $R0 ; exclude dir&lt;br /&gt;
 Exch&lt;br /&gt;
 Exch $R1 ; route dir&lt;br /&gt;
 Push $R2&lt;br /&gt;
 Push $R3&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
  ClearErrors&lt;br /&gt;
  FindFirst $R3 $R2 &amp;quot;$R1\*.*&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
  Top:&lt;br /&gt;
   StrCmp $R2 &amp;quot;.&amp;quot; Next&lt;br /&gt;
   StrCmp $R2 &amp;quot;..&amp;quot; Next&lt;br /&gt;
   StrCmp $R2 $R0 Exit&lt;br /&gt;
   IfFileExists &amp;quot;$R1\$R2\*.*&amp;quot; Jump DeleteFile&lt;br /&gt;
   &lt;br /&gt;
   Jump:&lt;br /&gt;
    Push &amp;#039;$R1\$R2&amp;#039;&lt;br /&gt;
    Push &amp;#039;$R0&amp;#039;&lt;br /&gt;
    Call DeleteFoldersWithExclusion&lt;br /&gt;
    &lt;br /&gt;
    Push &amp;quot;$R1\$R2&amp;quot; &lt;br /&gt;
    Call isEmptyDir&lt;br /&gt;
    Pop $0    &lt;br /&gt;
    StrCmp $0 1 RmD Next&lt;br /&gt;
   &lt;br /&gt;
   RmD:&lt;br /&gt;
    RMDir /r $R1\$R2&lt;br /&gt;
    Goto Next&lt;br /&gt;
   &lt;br /&gt;
   DeleteFile:&lt;br /&gt;
    Delete &amp;#039;$R1\$R2&amp;#039;&lt;br /&gt;
 &lt;br /&gt;
   Next:&lt;br /&gt;
    ClearErrors&lt;br /&gt;
    FindNext $R3 $R2&lt;br /&gt;
    IfErrors Exit&lt;br /&gt;
   Goto Top&lt;br /&gt;
 &lt;br /&gt;
  Exit:&lt;br /&gt;
  FindClose $R3&lt;br /&gt;
 &lt;br /&gt;
 Pop $R3&lt;br /&gt;
 Pop $R2&lt;br /&gt;
 Pop $R1&lt;br /&gt;
 Pop $R0&lt;br /&gt;
&lt;br /&gt;
FunctionEnd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Function isEmptyDir&lt;br /&gt;
  # Stack -&amp;gt;                    # Stack: &amp;lt;directory&amp;gt;&lt;br /&gt;
  Exch $0                       # Stack: $0&lt;br /&gt;
  Push $1                       # Stack: $1, $0&lt;br /&gt;
  FindFirst $0 $1 &amp;quot;$0\*.*&amp;quot;&lt;br /&gt;
  strcmp $1 &amp;quot;.&amp;quot; 0 _notempty&lt;br /&gt;
    FindNext $0 $1&lt;br /&gt;
    strcmp $1 &amp;quot;..&amp;quot; 0 _notempty&lt;br /&gt;
      ClearErrors&lt;br /&gt;
      FindNext $0 $1&lt;br /&gt;
      IfErrors 0 _notempty&lt;br /&gt;
        FindClose $0&lt;br /&gt;
        Pop $1                  # Stack: $0&lt;br /&gt;
        StrCpy $0 1&lt;br /&gt;
        Exch $0                 # Stack: 1 (true)&lt;br /&gt;
        goto _end&lt;br /&gt;
     _notempty:&lt;br /&gt;
       FindClose $0&lt;br /&gt;
       Pop $1                   # Stack: $0&lt;br /&gt;
       StrCpy $0 0&lt;br /&gt;
       Exch $0                  # Stack: 0 (false)&lt;br /&gt;
  _end:&lt;br /&gt;
FunctionEnd&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
Installer code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
  Push &amp;quot;x:\some\dir&amp;quot; &lt;br /&gt;
  Push &amp;quot;settings&amp;quot; 		;dir to exclude&lt;br /&gt;
  Call DeleteFoldersWithExclusion &lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Disk, Path &amp;amp; File Functions]]&lt;/div&gt;</summary>
		<author><name>BAPBAP</name></author>
	</entry>
</feed>