I have two directory structures. C:\Prototype\ and C:\Deployed\Branch\Customer\Code\
Under the Prototype directory are approximately 150 scripts.
Under the C:\Deployed\Branch\Customer\Code\ directory are over 4,000 scripts.
The original intent was any time a script in the Prototype directory was deployed to a Customer, under one or more Branch[es], that script code would be copied to correct location in the Deployed directory path. However, now we want to change things around. In order to make the necessary changes, we need to identify all occurrences of any script under the Deployed path that are the same (line for line) as the code in the Prototype directory. I need the full path, including filename written out to a file.
So, if I have the file a1.sql in C:\Prototype\ and a1.sql in C:\Deployed\Branch_a\Customer_a\Code\ and in C:\Deployed\Branch_b\Customer_a\Code\ and the code in C:\Deployed\Branch_a\Customer_a\Code\ is the same but the code in C:\Deployed\Branch_b\Customer_a\Code\ is different, I want to write a record that contains "C:\Deployed\Branch_a\Customer_a\Code\a1.sql".
If this sounds confusing, what we want to be left with after cleanup is a structure under C:\Deployed\... that contains only code that has been modified from the original Prototype code. I've played around with this quite a bit and am having trouble with the process to iterate through all the files and also with the code for comparing two files.
The way I envision this is to get a collection of filenames in the Prototype directory, then iterate through them. For each file, recurse through the Deployed directory, and when I find a matching filename, compare the contents of the two files. If they are the same, create a record with the path and filename to the file under the Deployed directory. After I've recursed through all directories, do the same with the next file. I know it can, and likely will take some time to execute, which is fine. We are not looking for lightning execution, just a way to cut down on the tedium of manually locating and comparing files.