That's a bit difficult to read. But what you basically seem to need is: glob, chdir, and File::Copy::move. So, what have you tried?
| [reply] |
What if you have BIG_1/SMALL_1/doc1 and also BIG_2/SMALL_1/doc1 (that is, matching file name in both paths), but those two files happen to be different? Would the file under BIG_1 always be the one to keep, or would you replace it with the version under BIG_2, depending on size or age or whatever?
Anyway, you might just want to create two lists, one for all the data files under BIG_1, and another for all the data files under BIG_2 (File::Find or one of its variants could help with that, or the gnu "find" command-line utility). Then, the files to move are the ones in the BIG_2 list that are not in the BIG_1 list.
Writing your script to store the lists in memory as separate hashes (with "SMALL_n/filename" as the hash keys) would make it quick and easy to tell which files need to be moved. Or, if the lists are sorted, you could just use the gnu "diff" and "grep" to compare the lists and get the files that appear only in BIG_2. | [reply] [d/l] [select] |
Guys thanks,
I just copied all subdirectories from BIG_1 into BIG_2 and their files were merged... :)
Thanks anyway...
| [reply] |
Not a perl solution, but may be good for you if you're on Linux:
find BIG_1 -type f -exec touch \{\} \;
cp -au BIG_2/* BIG_1/
This will update the modification time of all files in BIG_1 and than copy all files from BIG_2 which don't exist in BIG_1 to there (-u means update: copy only files which have no newer file of the same name at the target). | [reply] |