|
Answer» Hi All,
Could anyone help on this please. This is the scenario:
I have two parent folders with nested folders and files. The FOLDER contents are pretty much identical, although between the two, a file might be missing/exist in one folder, but not the other.
I have managed to generate two output files listing all files in each directory tree. The list gives the full paths.
My objective is now to be able to RECURSIVELY traverse both folders and perform the following:
1) Generate a report of all files that are not common to both directories, i.e. files appearing in one list but not the other.
2) Where a file appears in both lists, carry out a file compare to establish whether they differ. If they differ, echo the file name to a final output file.
Any ideas fellas?
Thanks.
Are you writing Windows Script or batch file logic? Also let us know your OS.
I'm also unclear about #2. What file name? The one from folder1 or folder2. Even though the file names are the same, they have different paths. There are two compare file commands (fc and comp) that may be helpful. Writing your own logic for file compare can be a nightmare, especially for files of unequal length (the files have to be resynched each time a difference is found).
Get back to us. Hi Sidewinder,
Sorry if I failed to explain fully. Now then, here goes:
Let's look at it this way:
Say I have made two software releases. All source code are held in a source control repository.
I now need to identify the following:
1/ Which files are deprecated from the older release
2/ Which files are in the new release, but not in the old
3/ Which files were common to both, but are modified
Sadly, my source control tool does not have the capability of carrying out the above and so I have to rely on good and trusted batch scripting.
As such, I proceed to export all files making up each release to two locations, in order to carry out a file compare.
I now want to recursively compare the files within each folder, making sure the comparison starts from a common folder name at each location, e.g. \myFiles\.., as PER below.
\\server1\myFiles\print.java - Revision 1 (Release 1)
\\ server2\myFiles\print.java - Revision 2 (Release 2)
Note that the fact we have different revisions for the above file does not necessarily mean they are different by content.
Now by way of a batch COMMAND, I wish to carry out a compare of both revisions.
Should my comparison reveal that the two revisions differ, the next step will be to carry out a specific action, such as a deployment of the NEWER revision, to a specified location. If they're the same, no action is carried out.
I hope you've now got a gist of what this is all about. By the way, my OS is XP Professional.
Thanks for your assistance.
Batch language. Hmmmmm.
Just some pseudo code. You may get some ideas. I sure hope the directory trees on both servers are identical. Code: [Select] set server1=\\server1\myFiles set server2=\\server2\myFiles
for /f %a in ('dir /a:-d /b /s %server2%\*.*') do ( call set pgm=%%%a:~18% if exist %server1%\%pgm% (echo ver1:yes ver2:yes %%a) else (echo ver1:no ver2:yes %%a) )
for /f %a in ('dir /a:-d /b /s %server1%\*.*') do ( call set pgm=%%%a:~18% if exist %server2%\%pgm% (who cares, do nothing, posted in first FOR) else (echo ver1:yes ver2:no %%a) )
Questions:
1. If pgm is in ver 1 and ver 2, does not ver 2 trump ver 1?
2. If pgm is in ver 2 but not ver 1 is this not a new pgm?
3. If pgm is in ver 1 but not ver 2: pgm deprecated? pgm unchanged from ver 1? copy to ver 2?
Arrays might work too, but you'd suck the all the oxygen out of the environment space. I can't see any reason to do file compares, but maybe I'm missing something.
Hope this helps.
|