Oye, saw something wrong with my code sorry... here is the fixed version....

#Used to find files use File::Find; #Used to move files to new location use File::Copy; #Some defined variables my $dir_count = 1; #Keeps count of directories of each chunk my $total_size = 0; #Used to count toltal count of file sizes my $dir_chunk = 10000000; #Size directory should be (aka chunk) #Starts the actual File Search & Replace print "Starting Search and Replace - \n"; find (\&eachFile, "/asdf/"); print "Completed\n"; sub eachFile { my $filename = $_; my $fullpath = $File::Find::name; #remember that File::Find changes your CWD, #so you can call open with just $_ if(-f "$fullpath"){ my $size = -s $fullpath; $total_size+=$size; if($total_size > $dir_chunk) { $total_size=$size; $dir_count++; } my $move_dir = "/chunks/$dir_count/"; if(!(-e "$move_dir")) {mkdir("$move_dir",0777);} print "\t$filename to $move_dir\n"; move("$fullpath","$move_dir$filename"); } }

I am the first overweight, very tall munchkin... be very amazed.


In reply to Re: file chunk algorithm by thealienz1
in thread file chunk algorithm by thealienz1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.