Re: Find files are SYN or Not in Two Folders



On Mar 17, 7:23 pm, "Paul Randall" <paul...@xxxxxxx> wrote:
"ashoksganesh" <ashoksgan...@xxxxxxxxx> wrote in message

news:329799c3-5728-4bc3-93b1-c0d8e61cb942@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Here wat am trying to acheive.

1) I have a Folder A and Folder B.
"
2)i want to check the files are sync in Folder A and Folder B,using
time frame

Now what am trying to do is

1)check the file in FolderA and grab the files from 9Am to 12 Pm go to
Folder B and find the file is exist or not.
2)This script should run every three hours to find the syn or non sync
between FolderA and Folder B files.

definitely there should be some easy way to do this,but i checked
different forum,i didn't get a right way to pursuit this,please help
me to
solve this issue.

Thanks in Advance

Here is the one i wrote just for count

****************************************************************
Dim oFS, SourceFolder,DestFolder,Source,Dest,demofolder,foldername
set oFS =CreateObject("Scripting.FileSystemObject")
set SourceFolder = oFS.GetFolder("c:\sourcefolder")
Set DestFolder=oFS.GetFolder("c:\destfolder")
foldername=demofolder.Name
Source= SourceFolder.Files.Count
Dest= DestFolder.Files.Count
If Source=Dest Then
WScript.Echo "SYNC"
Else
WScript.Echo "NON SYNC"
End if

******************************************************************

Not sure how to insert time frame in this script,please lead me.

Thanks

It is relatively easy to script checking that all files that exist in
sourcefolder also exist in destfolder, and maybe you would also have to
verify that all files in dest folder also exist in source folder.  This does
not mean that the files are identical, only that they exist.

Perhaps you need some way to verify the files are actually the same.
Microsoft has a tool to help with this task.http://www.microsoft.com/downloads/details.aspx?FamilyID=B3C93558-31B...
FCIV is a command line tool which can produce SHA1 or MD5 checksums for all
the files in a folder and its subfolders.  Alternately, it can produce an
XML-formatted text file with checksum info.  Later, FCIV can then use this
XML file as input when the tool is used to verify that everthing listed in
the XML file exists identically in the original or some other folder.   The
script could be set up to read STDOUT while the command line is executed,
and and report any problems.

If you are interested in this, post a reply here and I will clean up and
post a sample script.

-Paul Randall- Hide quoted text -

- Show quoted text -

Hey Paul,

Sorry for the late reply,already i strat using FCIV (the code created
by EHVBS)in the script,but wat am tring to achieve here is

Use the date range or today's date file to compare and ignore the
previous day's files.

Here is the scritp :

**********************************************************************************************************

Dim oFS : Set oFS = CreateObject
( "Scripting.FileSystemObject" )
Dim aDirs : aDirs = Array( ".\sourcefolder", ".\destfolder" )
Dim dicGrps : Set dicGrps = CreateObject( "Scripting.Dictionary" )
Dim fncClas : Set fncClas = GetRef( "getIdentityOfFile" )
Dim sDir
For Each sDir In aDirs
' WScript.Echo "processing", sDir
Dim oFiles : Set oFiles = oFS.GetFolder( sDir ).Files
Dim oFile
For Each oFile In oFiles
' WScript.Echo " processing", oFS.GetBasename( oFile.Name ),
oFile.Path
Dim sProp : sProp = fncClas( oFile )
If Not dicGrps.Exists( sProp ) Then
dicGrps.Add sProp, CreateObject( "Scripting.Dictionary" )
' WScript.Echo " adding property/group", sProp, "to
dictonary"
End If
dicGrps( sProp )( oFile.Path ) = 0
'WScript.Echo " adding file ", oFile.Path, "to dictionary
for property", sProp
Next
Next

Dim bSync : bSync = True
Dim sKey, aKeys
For Each sKey In dicGrps.Keys
If 1 = dicGrps( sKey ).Count Then
aKeys = dicGrps( sKey ).Keys
WScript.Echo " Group", sKey, aKeys( 0 )
bSync = False
End If
Next
If Not bSync Then
WScript.Echo Join( aDirs, ", " ) & " Files are not in sync"
Else
WScript.Echo Join( aDirs, ", " ) & "All Files are SYNC"
End If
Function getIdentityOfFile( oFile )
Dim oShell : Set oShell = WScript.CreateObject( "WScript.Shell" )
Dim sCmd : sCmd = "fciv -add """ & oFile.Path & """ -md5"
' WScript.Echo sCmd
Dim sDigest : sDigest = oShell.Exec( sCmd ).Stdout.ReadAll
WScript.Echo sDigest
Dim aParts
aParts = Split( sDigest, vbCrLf )
sDigest = Left( aParts( UBound( aParts ) - 1 ), 32 )
WScript.Echo sDigest
getIdentityOfFile = sDigest
End Function
.



Relevant Pages

  • Re: Rolling back folders delete using VBA
    ... created at run time) with same sub folder structure. ... if we come accross an error while deleting a file from original location. ... Dim oSubFolder As Object ... Dim oFile As Object ...
    (microsoft.public.excel.programming)
  • Re: HTML Item properties vs. Regular item properties
    ... I don't use the MSN provider, but AFAIK the date in the default store's is ... OutlookSpy - Outlook, CDO ... as well as the Sent Items folder on the MSN server. ... Dim app As Outlook.Application ...
    (microsoft.public.outlook.program_vba)
  • RE: If Statement help
    ... Dim newbk As Variant ... Right now the macro takes all the files in the current folder, ... 'This is very useful in quickly archiving and storing daily batch files ... Dim objFile As File, strSourceFolder As String, strDestFolder As String ...
    (microsoft.public.excel.programming)
  • RE: If Statement help
    ... Dim newbk As Variant ... Right now the macro takes all the files in the current folder, ... 'This is very useful in quickly archiving and storing daily batch files ... Dim objFile As File, strSourceFolder As String, strDestFolder As String ...
    (microsoft.public.excel.programming)
  • RE: If Statement help
    ... "Denise Pollock" wrote: ... Dim newbk As Variant ... Right now the macro takes all the files in the current folder, ... Dim objFile As File, strSourceFolder As String, strDestFolder As String ...
    (microsoft.public.excel.programming)