I've got a large folder of over 9000 files all of which are pages in books. The name of the book is contained in the name of the file (i.e. unknown_U036_Box 02_Analysis Neutral final State Reaction Bradley Werner_0045) where "Analysis Neutral final State Reaction Bradley Werner" is the name of the book and "0045" is the page number. There are many different books in the folder. I'm trying to categorize the pages in folders based on the book title. The idea is that a file, such as the one named above, would get moved into a folder called "Analysis Neutral final State Reaction Bradley Werner". Here's what I've got.
$dir = getcwd(); find(\&book, $dir ."/Book Chapter"); my @bookFiles; sub book{ next if (-l && !-e ); push (@bookFiles, $File::Find::name) if (( $_ =~ m/\.txt$/) || ($_ + =~ m/\.jpg$/) || ($_=~ m/\.tif$/)); } my @bookNameArray; my $bookName; my @bookFileName; for(my $h = 0; $h < scalar(@bookFiles); $h++){ @bookNameArray = split(/_/ , $bookFiles[$h]); @bookFileName = split("/" , $bookFiles[$h]); $bookName = $bookNameArray[-2]; mkdir( $dir . "/Book Chapter/" . $bookName); move($bookFiles[$h], $dir . "/Book Chapter/" . $bookName . "/" . $b +ookFileName[-1]); }
It's moving most of the files into the folders perfectly, however, some are not getting moved at all. If I put a die command on the move function, it quits when I get to one it won't move. Any ideas on why it is not working?

In reply to move() error by JKasting

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.