Compare the folder

What's the best method to find the different files from  A folder and B folder ?
ginluAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VbmasterCommented:
Here's the easy way:

* Create a list of files in folder A -> save in Array1
* Create a list of files in folder B -> save in Array2
* Add the characters ",1" to every item in Array1
* Add Array2 to Array1, be sure to add ",2" to every item
* Sort Array1
* Iterate thru all items in Array1, and see what non-duplicates exist (duplicates here means where everything but the two characters are the same)
0
jimkanCommented:

Use a reference to Microsoft Scripting Runtime. It always exists among your references.

Dim oObject As New FileSystemObject
Dim oFolder As Folder
Dim oFile   As File
Dim oArray As New Scripting.Dictionary

Set oFolder = oObject.GetFolder(App.Path & "\Ko")
For Each oFile In oFolder.Files
    oArray.Add oFile.Name, 1
Next oFile

Set oFolder = oObject.GetFolder(App.Path & "\Ka")
For Each oFile In oFolder.Files
    If not oArray.Exists(oFile.Name) Then txtFiles.SelText = oFile.Name & " does not exist in " & oFolder.ShortPath & vbNewLine
Next oFile
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VbmasterCommented:
jimkan: it does NOT always exist there!! <g>

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

jimkanCommented:
I have so far never seen a machine that got VB installed that do not have Microsoft Scripting RunTime among his/her references.
Microsoft Scripting Runtime is included in the Internet Explorer Package.
If you are a VB coder that do not use Internet Explorer, then it may be missing, but then those coders aint many =).
0
jimkanCommented:
Just forgot:

Let ginlu check if he got Microsoft Scripting Runtime in
"Projects => References"

Sincererly Jim
0
VbmasterCommented:
Well, I don't think you've seen that many machines then. I am proud of belonging to 'the few people' according to you that do NOT have it installed. ;)
0
ginluAuthor Commented:
Thanks for your answer!
But this kind of compare is just find different filename ,how can i find out the change files....
0
VbmasterCommented:
If you use the 'system' I mentioned you can store date too i.e. you get

\Directory\Filename.Ext,1999-10-12 01:01:01,1

This will make the two

\Directory\Filename.Ext,1999-10-12 01:01:01,1
\Directory\Filename.Ext,1999-10-12 01:01:02,2  <- one sec newer

different and it will still be left when you have iterated thru the array. You will have to ignore everything you get on the last step that has a ",1" as 2 last characters.

I think I can fix you up with some code if you get stuck, but I let you try this first ;)


0
VbmasterCommented:
If you use the 'system' I mentioned you can store date too i.e. you get

\Directory\Filename.Ext,1999-10-12 01:01:01,1

This will make the two

\Directory\Filename.Ext,1999-10-12 01:01:01,1
\Directory\Filename.Ext,1999-10-12 01:01:02,2  <- one sec newer

different and it will still be left when you have iterated thru the array. You will have to ignore everything you get on the last step that has a ",1" as 2 last characters.

I think I can fix you up with some code if you get stuck, but I let you try this first ;)


0
VbmasterCommented:
Sorry for the duple-post, I really like double-clicking on things I guess.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.