It took a few minutes to write and well less than a second to run on a directory structure containing 12 MB of file in 60 folders and 520 files. Why do you think that? Have you tried it? Was the code too slow? Yesterday I wrote a trivial script to crawl a directory structure and count lines of code in source files. This option could generate a very long report and may take a long time. How does "Give me code" eq "Learning Perl"? Write some code, try it out, find issues, clearly describe the issues here with runable code, then we can help you learn effectively. "How do I compute the difference of two arrays? How do I compute the intersection of two arrays?" in perlfaq4 or my node here. For example, I might make the keys the MD5 sums and the values an arrayref of filenames, and then I'd basically do union and difference operations on the keysets. using File::Find, storing the data I want to compare (be it filenames or checksums) in two hashes, one for each directory. The basic idea I've used is to build a list of files, e.g. I've written scripts like this a few times, unfortunately not really ready to share here. Re: perl script to compare two directories $MODE=4 If the two directories contain two files with the same name, same size, then the program will compare those files byte for byte and display the difference in detail for each file. If the MD5 hash does not match, then those files are listed along with the hash values. $MODE=3 Compares the MD5 hash of files that appear to be same. $MODE=2 Also compares file sizes and dates and tells you which file is younger/older or larger/smaller. $MODE=1 compares whether the same files exist in both places. Shows you the total size of both directories and the number of files/directories they contain. $MODE=0 Prints a quick summary of both directories. $DIR2 will contain the full path to directory 2 $DIR1 will contain the full path to directory 1 My question is, do you know any existing Perl scripts that can do this? I would like to write a script that compares two directories and prints the differences. I began learning Perl a few years ago as a hobby.
0 Comments
Leave a Reply. |