<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Php Mysql &#187; SVN</title>
	<atom:link href="http://phpmysql.co.in/tag/svn/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpmysql.co.in</link>
	<description>My experience with Open Source Technologies - VINOD</description>
	<lastBuildDate>Thu, 24 Nov 2011 13:44:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Delete all SVN files/folders within a folder recursively</title>
		<link>http://phpmysql.co.in/php/delete-all-svn-files-folders-within-folder-recursively/</link>
		<comments>http://phpmysql.co.in/php/delete-all-svn-files-folders-within-folder-recursively/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 21:19:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[fopen]]></category>
		<category><![CDATA[Recursive]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://phpmysql.co.in/?p=196</guid>
		<description><![CDATA[The other day I came across with a problem when I were to upload the complete code base from development server to production server, my code was versioned with svn-subversion so there were svn related files &#38; folders in each folder of my code base. So before uploading code to the production server, I wanted [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I came across with a problem when I were to upload the complete code base from development server to production server, my code was versioned with svn-subversion so there were svn related files &amp; folders in each folder of my code base. So before uploading code to the production server, I wanted to clean up all my code from svn files/folders.</p>
<p>Note I was using windows machine &amp; accessing code base on a linux machine in my local network using Samba Share</p>
<p>I found an option &#8216;export&#8217; in svn client (Tortoise SVN), which export all the code quite well, so I thought I got the solution, but problem came when I couldn&#8217;t get svn ignored files in the exported code &amp; above all I can&#8217;t see the ignored icon on the file/folder because my codebase was on some other machine in my local network (LAN). And folder structure of my codebas was too complex &amp; big to find svn ignored files/folders.</p>
<p>So I just written a simple php script to browse all files &amp; folders recursively &amp; delete all the svn related files &amp; folders from the code base.</p>
<p><strong><span style="color: #ff0000;">NOTE:</span></strong> Please take a backup of all your code before executing this script, else you may loss your code.</p>
<pre>&lt;?php

$Src = "/var/www/html/project/";//put forward slash at end of path

function DeleteRecursive($Dir) {

    if (is_dir($Dir))
    {
        $handle=opendir($Dir);
        while ($file = readdir($handle))
        {
            if(is_dir($Dir.$file) &amp;&amp; $file!="." &amp;&amp; $file!="..") {

                 if($file == ".<span class="il">svn</span>") {
                     RD($Dir.$file."/");
                 }
                 else {
                     DeleteRecursive($Dir.$file."/");
                 }
             }
        }
        closedir($handle);
    }
    else {
        echo "Directory:&lt;b&gt;$Dir&lt;/b&gt; doesn't exist";
        exit();
    }
}

function RD($Dir) {

    if (is_dir($Dir))
    {
        $handle=opendir($Dir);

        while ($file = readdir($handle))
        {
            if(is_dir($Dir.$file) &amp;&amp; $file!="." &amp;&amp; $file!="..") {
                RD($Dir.$file."/");
            }

            elseif($file!="." &amp;&amp; $file!="..") {
                echo "DELETING FILE:".$Dir.$file."&lt;br&gt;";
                unlink($Dir.$file);
            }

        }
        closedir($handle);
        echo "DELETING DIR:".$Dir."&lt;br&gt;";
        rmdir($Dir);
    }
    else {
        echo "Directory:&lt;b&gt;$Dir&lt;/b&gt; doesn't exist";
        exit();
    }
}

echo "Deleting All SVN related Files &amp; Folders from the directory - &lt;b&gt;$Src&lt;/b&gt; (Including Sub-Directories)&lt;br&gt;";
DeleteRecursive($Src);
?&gt;</pre>
<p>Your comments &amp;  suggestion are welcome</p>
<p>Happy Reading <img src='http://phpmysql.co.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://phpmysql.co.in/php/delete-all-svn-files-folders-within-folder-recursively/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

