| |
Raknahs
Posts: 62
Score: 0
Joined: 12/5/2006
Status: offline
|
hi, I am just working on a vbscript which used to compare a specif file in a souce folder and destination folder. Let me explain clearly. I have 2 server 1. Production server and the Backup server. Everday the new files getting create into the production server for ex. First day the following files getting created lcms_20071001.bak,master_20071001.bak,prd_20071001.bak. second day the following files getting created lcms_20070201.bak,master_20070201.bak,prd_20070201.bak Keep on creating every day. I want to copy the production server files into the backup server. Every week i am copying thru manually. I planned to develop a script. I dont want to copy all the files available in the production server, need to copy only a specific files. for ex. lcms_20071001.bak,lcms_20070201.bak. I need two things from this script. 1. The specific files which is available in the production server has to update in the destination server i.e. backup server. 2. The Destination server has to verify the files from the source server. If any files find in the destination server but not find in the source server, The files which is available in the destination server has to remove immediately. I have developed a script, the problem in the script is it used to compare all the files its not taking a specific files. 1. The script is updating all the files from the source server to the destination server 2. Destination server verify all the file from the source server any files not available in the source folder the destionation folder gets deleted immediately. if any one can help me out to solve this issue it would be great helpful for me. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objNetwork = wscript.CreateObject("wscript.network") SOURCE_FOLDER = "\\hpim\e\sourcetest\" DESTINATION_FOLDER = "\\hplm\d\test_dst\" ReplicateFiles objFSO, SOURCE_FOLDER, DESTINATION_FOLDER Sub ReplicateFiles (objFSO, strSourcefolderpath, strDestinationfolderpath) Dim aSourceFilearray Dim aDestinationfilearray Dim Sourcefilelist Dim Destinationfilelist Dim oFileSource Dim osourcename Dim osourcefile Dim oFileDestination Dim bSourceExists Dim bDestinationExists On Error Resume Next Set aSourceFilearray = objFSO.GetFolder(strSourcefolderpath) Set Sourcefilelist = aSourceFilearray.Files Set aFileArrayDestination = objFSO.GetFolder(strDestinationfolderpath) Set FileListDestination = aFileArrayDestination.Files For each oFileSource in Sourcefilelist str1= Mid(oFileSource,15,12) str2 = Mid(oFileSource,27,8) str3 = Mid(oFileSource,35,4) If str1 = "lcms_backup_" then osourcename = str1&str2&str3&".bak" WScript.Echo osourcename End If For each oFileDestination in FileListDestination bDestinationExists = 0 Set sourcefile = objfso.GetFile(osourcename) If sourcefile.Name = oFileDestination.Name then If sourcefile.DateLastModified = oFileDestination.DateLastModified Then bDestinationExists = 1 Exit For End If End If Next If bDestinationExists = 0 then sourcefile.Copy strDestinationfolderpath & "\" sourcefile.Name MsgBox "copy" End If Next For each oFileDestination in FileListDestination bSourceExists = 0 For each oFileSource in FileListSource If oFileDestination.Name = Sourcefile.Name then If oFileDestination.DateLastModified = Sourcefile.DateLastModified then bSourceExists = 1 Exit For End If End If Next If bSourceExists = 0 then oFSO.DeleteFile strDestinationfolderpath & "\" oFileDestination.Name,true End If Next msgbox "Files Replicated Successfully" End Sub Thanks Ravi
|
|