PaulRKrueger
asked on
VBscript combine lists of files, remove duplicates
I'm using a vbscript to examine and combine a set of text files in two separate folders. I need to take the file list from each folder, combine them, and remove any duplicates (note, I'm talking about the file list, not file manipulation at this point).
For example...
Files in source folder 1:
file1.txt
file2.txt
file3.txt
Files in source folder 2:
file1.txt
file3.txt
file5.txt
The resulting list should read:
file1.txt
file2.txt
file3.txt
file5.txt
I don't need to know anything specific about the files (date modified, etc.), I just need a list that I can then diagrammatically move through. I'm using the following code to pull the folder lists, however, I'm perfectly open to using a different method.
For example...
Files in source folder 1:
file1.txt
file2.txt
file3.txt
Files in source folder 2:
file1.txt
file3.txt
file5.txt
The resulting list should read:
file1.txt
file2.txt
file3.txt
file5.txt
I don't need to know anything specific about the files (date modified, etc.), I just need a list that I can then diagrammatically move through. I'm using the following code to pull the folder lists, however, I'm perfectly open to using a different method.
option explicit
Dim objFSO, A, B, FLD, strFolder, item
set objFSO = CreateObject("Scripting.FileSystemObject")
strFolder = "\\<network path>\LogonErrors"
set FLD = objFSO.GetFolder(strFolder)
set A = FLD.Files
strFolder = "\\<network path>\LogonSuccess"
set FLD = objFSO.GetFolder(strFolder)
set B = FLD.Files
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
This is absolutely perfect. Thank you. Works like a charm and fits my need for a vbscript.
That's cool you preferred VBS, I knew that could be the case going in.
Just so you know, there is one downside to that approach. ALL of the entries that were new from the second file will follow ALL of the entries from the first file. They won't be in a sorted order in the output file, but rather the order they were added to the dictionary object. The batch approach addressed that, but it may not matter to you.
Glad you got a useful solution.
~bp
Just so you know, there is one downside to that approach. ALL of the entries that were new from the second file will follow ALL of the entries from the first file. They won't be in a sorted order in the output file, but rather the order they were added to the dictionary object. The batch approach addressed that, but it may not matter to you.
Glad you got a useful solution.
~bp
Open in new window
~bp