in reply to Re^3: File copy based on conditions in two arrays
in thread File copy based on conditions in two arrays
About your parameter checking, what I meant is that the code where you display "usage: ..." and exit is AFTER you call the functions working with your parameters. You should put it before, and merely check that you have parameters, or display usage and exit.
I also advise you to put solid parameter checking in your functions, when performance is not an issue. It is much better to have a function die with an explicit message like "ERROR: myFunctionName() expected 3 parameters" if some expected parameters are undefined, for instance, than have it behave unexpectedly, in a silent way.
What I was getting at is that you separate the directory name, and the file name, in your algorithm, and then check only the file name. Hence, you may overwrite your files several times.
For instance, you have directory A, containing directories A1 and A2, each of those having a file named 'a'. Then, in directory B, you have a file named 'a'. Well, now you iterate:
First, you would work for A/A1/a, compare it with B/a, and, depending on the MD5, replace or keep B/a.
Then, you would work for A/A2/a, compare it with B/a, and, depending on the MD5, replace or keep B/a.
Somehow, I doubt that was what you were wanting to do :)
|
|---|