Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backing up all folder and subfolder recursively , i am stuck.

Status
Not open for further replies.

bolobaboo

MIS
Aug 4, 2008
120
US
Got following code and trying to twick, But unable to fix it. Any idea ?

Option Explicit
Backup "C:\Temp\tmp", "C:\Temp\restore"
FUNCTION Backup (RepSource,RepDest)
DIM objSource(1), objDest, objDestCompare, objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
SET objSource(0)=objFSO.GetFolder(RepSource)
IF NOT objFSO.FolderExists(RepDest) THEN objFSO.CreateFolder(RepDest)
FOR EACH objFile IN objSource(0).Files
objSource(1)=objFSO.BuildPath(RepSource,objFile.name)

objDest=objFSO.BuildPath(RepDest,objFile.name)

IF objFSO.FileExists(objDest) THEN
SET objDestCompare=objFSO.GetFile(objDest)
PROCESSFILE
IF objDestCompare.Size<>objFile.Size Or objDestCompare.DateLastModified<>objFile.DateLastModified THEN
objFile.Copy objDest,TRUE
PROCESSFILE
END IF
ELSE
objFile.Copy objDest,TRUE
PROCESSFILE
END IF

NEXT
SET objSource(0) = NOTHING
SET objSource(1) = NOTHING
SET objDest = NOTHING
SET objDestCompare = NOTHING
END FUNCTION
FUNCTION PROCESSFILE
objExplorer.Document.Body.InnerHTML = "Your backup is now being processed" & _
"<br><br>File " & intFileCount & " of " & strCountTheFiles & " has been copied.<br><br>" & _
"This may take several minutes to complete."

intFileCount = intFileCount + 1

IF IsError(err) = TRUE THEN

LogIt("Backed up file # " & intFileCount & " Had and error.")

SET strLogFileName = NOTHING

ELSE
strLogFileName = objFile.Name

LogIt("Backed up file # " & intFileCount & " " & RepSource & "\" & strLogFileName)

SET strLogFileName = NOTHING

END IF
END FUNCTION
 
Specifying Option Explicit requires that all variables be defined so make sure that you are defining them all. If you get an error saying variable undefined, then declare it.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top