I'm trying to optimize my project's file server. the folder structure is like this
--- Parent A |---Sub B (Sub folder of Parent A) |------Sub C (Sub folder of Sub B) |--- File A (File within Sub C) |--- File B (File within Sub C) |------Sub D (Sub folder of Sub B) | --- File A (File within Sub D) | --- File C (File within Sub D) -- Parent B ....likewise many parent folders
Over the time the file server has huge number of files and duplicates.. Here Sub C ->File A and Sub D --- File A are same to some extent but one of the them is newer. I'm trying to consolidate it as


1. If I decide to retain only Folder Sub C

a. Check for duplicate files (like File A) in both Sub D & Sub C.

b. Check which File A (other duplicate files too) is newer comparing Sub D & Sub C

c. Copy the newer file to Sub C

d. Copy rest of the files to Sub C from Sub D
My Problems are:
1. Comparing time stamps - use of stat() ..dont know how to use "WIN32_SLOPPY_STAT"

2. Recursive search which one to use - grep?

- Use of XCopy?!!
I found File::Xcopy update|UD - copy files only if 1) the file exists in the target and 2) newer in time stamp http://search.cpan.org/~geotiger/File-Xcopy-0.12/Xcopy.pm#xmove($from,_$to,_$pat,_$par) Any help pls...?!!!!!

In reply to Retaining the most recent file in a FS by hiradhu

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.