<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>yuvaraj</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/yuvaraj/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/yuvaraj/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/yuvaraj//969</id>
    <updated>2011-08-18T08:59:10Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Directory size calculator</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/yuvaraj/2011/08/directory-size-calculator.html" />
    <id>tag:blogs.perl.org,2011:/users/yuvaraj//969.2110</id>

    <published>2011-08-18T08:48:22Z</published>
    <updated>2011-08-18T08:59:10Z</updated>

    <summary>#!c:\perl print &quot;Enter a directory \n&quot;; chop ($dir=STDIN); $i=0; $store[$i]=$dir; $i++; readfiles(); sub readfiles { foreach $dir (@store) { opendir (DIR, $dir) or die &quot;failed to open:$!&quot;; @thefiles= readdir(DIR); closedir(dir); foreach $f (@thefiles) { unless ( ($f eq &quot;.&quot;) ||...</summary>
    <author>
        <name>yuvaraj</name>
        
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/yuvaraj/">
        <![CDATA[<p>#!c:\perl<br />
print "Enter a directory \n";<br />
chop ($dir=STDIN);<br />
$i=0;<br />
$store[$i]=$dir;<br />
$i++;<br />
readfiles();</p>

<p>sub readfiles<br />
{<br />
foreach $dir (@store)<br />
{<br />
opendir (DIR, $dir) or die "failed to open:$!";<br />
@thefiles= readdir(DIR);<br />
closedir(dir);<br />
foreach $f (@thefiles)<br />
{</p>

<p> unless ( ($f eq ".") || ($f eq "..") )<br />
 {<br />
 #print "$f \n";<br />
 $path=join("",$dir,"/",$f);<br />
 #print "$path \n";<br />
 if ( -d $path)<br />
  {<br />
	#print "$f a directory \n";<br />
	<br />
	$store[$i]=$path;<br />
	$i++;<br />
   }<br />
 else<br />
   {<br />
   @fsdata=stat($path);<br />
   $a+= $fsdata[7];<br />
   }<br />
     <br />
 }<br />
}<br />
}<br />
print "$a \n";<br />
}</p>

<p>foreach $store (@store)<br />
{</p>

<p> print "$store \n";<br />
 }</p>

<p></p>

<p>The above script will help in calculating the size of the directory.</p>]]>
        
    </content>
</entry>

</feed>
