My question is about saving many files from many directories in only one directories by keeping all old versions of the files. I have about 10 directories with very similar files (10 backup directories made using Linux, Windows and MacOS). I want to concatenate these 10 directories in only one. For example, I have 3 directories a, b and c with the following contents:
a
- fileA.txt (date 10/10/2012)
- fileB.txt (date 10/12/2012)
- fileC.txt (date 01/05/2013)
b
- fileA.txt (date 10/01/2013)
- fileB.txt (date 10/02/2013)
- fileC.txt (date 01/05/2013)
- fileD.txt (date 02/05/2013)
c
- fileA.txt (date 10/10/2012)
- fileB.txt (date 12/02/2013)
The resulting directory must be:
- fileA.txt (date 10/01/2013 from b)
- fileA.txt_20121010hhmmss (from a and c (same file))
- fileB.txt (date 12/02/2013 from c)
- fileB.txt_20121210hhmmss (from a)
- fileB.txt_20130210hhmmss (from b)
- fileC.txt (date 01/05/2013 from a and b (same file))
- fileD.txt (date 02/05/2013 from b)
hh=hours mm=minutes ss=seconds
Currently I am working on a Perl script which can compare the files using function "compare" and a md5 checksum.
I order to find the modify date (if the files are differents), I am using the Metadata (when I can) using Exiftool (few compatible files like docx, ppt pdf jpg...) otherwise I am using the timestamp using stat command.
The file without the added extension must be the more recent of all the files with the same name.
The Perl script is very slow and complex therefore I am looking for a more robust solution.
Thank you for your help.
NB: - I want to use this solution on a Synology server (DS212) on which I only have really few classical shell commands. If necessary, I can copy these files on a linux (or OSX) machine to do this.