Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to compare files from two diff folders
#1
Not Solved
Hey Friends ... please can you help me on this ..

scenario: I got two folders one is old version folder and other is new version folder.. There are about 100 files in that folder.. so i need to compare each one filein old version folder with other file in new version folder ,I have written below code .. it is working if i mention path for each file..but I need to put in loop so that it checks all files in the folders...

Code:
Option explicit
Dim File_Sys_Obj, File_Obj1, File_Obj2, Old_V_Folder, New_V_Folder, OVFiles, NVFiles, OFile, NFile, Str2, Str1 ,File ,Name_File,fldext                                    
Set File_Sys_Obj = createobject("Scripting.FileSystemObject")                                          
Set Old_V_Folder =  File_Sys_Obj.GetFolder("U:\Similar")  
Set  New_V_Folder = File_Sys_Obj.GetFolder("U:\Different")  
Set OVFiles =Old_V_Folder.Files
Set  NVFiles = New_V_Folder.Files
NFile ="U:\Different\first.txt"
OFile ="U:\Similar\first.txt"
For  each File  in OVFiles
'z = File.name
Name_File = File.path
Set File_Obj1 = File_Sys_Obj.OpenTextFile(Name_File,1,false)
Set File_Obj2 = File_Sys_Obj.OpenTextFile(NFile,1,false)
While  File_Obj1.AtEndOfStream <> true
Str1= File_Obj1.ReadAll
Str2= File_Obj2.ReadAll
If  StrComp(Str1, Str2, 0)   <> 0 Then
Msgbox "Files not Identical"
If File_Sys_Obj.FolderExists("U:\HeyNotSim")then
File_Sys_Obj.CopyFile "U:\Similar\first.txt","U:\HeyNotSimi/first.txt",True
Else    
File_Sys_Obj.CreateFolder("U:\HeyNotSimi")
File_Sys_Obj.CopyFile "U:\Similar\first.txt","U:\HeyNotSimi\",True
End If
reporter.ReportEvent micFail, " Two Files Are Not  Similar","Failure"
Else
Msgbox "Files Identical"
'fso.CopyFile "C:\Users\sarishr\Desktop\first.txt","C:\Users\sarishr\Desktop\Similar\first.txt",True
Reporter.ReportEvent micPass, "Two Files Are Similar"," Sucess"
End If
Wend
Next
Set File_Obj1 = Nothing
Set File_Obj2 = Nothing
Set OVFiles = Nothing
Set NVFiles = Nothing
Set Old_V_Folder=Nothing
Set  New_V_Folder = Nothing
Set   File_Sys_Obj = Nothing
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy folders from ALM squadri 0 1,686 08-16-2016, 06:23 PM
Last Post: squadri
  Compare 2 image files in Beyond Compare through QTP arpan 0 3,802 10-16-2013, 02:39 AM
Last Post: arpan
  Need to compare two text files - ignoring some text nelly27281 2 4,373 09-09-2012, 12:09 PM
Last Post: freeboynil
  compare 2 pdf files maktha1 0 2,233 11-17-2011, 07:13 AM
Last Post: maktha1
  How to perfrom a same operation on diff. page. ? njnirmal 5 4,217 08-17-2009, 12:25 PM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)