Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


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

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64935
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Backing up all folder and subfolder recursively , i am stuck.
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Backing up all folder and subfolder recursively , i am ... - 10/9/2008 5:09:32 AM   
  bolobaboo

 

Posts: 3
Score: 0
Joined: 10/9/2008
Status: offline
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
 
 
Post #: 1
 
 RE: Backing up all folder and subfolder recursively , i... - 10/10/2008 3:04:34 AM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
What's wrong? What errors do you get?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to bolobaboo)
 
 
Post #: 2
 
 RE: Backing up all folder and subfolder recursively , i... - 10/12/2008 2:43:41 AM   
  bolobaboo

 

Posts: 3
Score: 0
Joined: 10/9/2008
Status: offline
Hi
variable undefined "objfile"

any idea ?

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Backing up all folder and subfolder recursively , i... - 10/12/2008 7:34:17 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
Not sure but...
Try calling the function with objFile as a variable like this:

PROCESSFILE objFile

Then change the header of the function like this:

FUNCTION PROCESSFILE(MyFile)

and replace "objFile" by "MyFile" inside the function.

If doesn't work verify that objFile is a valid path. Eventualy use

For Each File in  objSource(0).Files
Set objFile = objFSO.GetFile(File)
...
Next

HTH

_____________________________

Fred

(in reply to bolobaboo)
 
 
Post #: 4
 
 RE: Backing up all folder and subfolder recursively , i... - 10/12/2008 7:36:48 AM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
quote:

ORIGINAL: bolobaboo

Hi
variable undefined "objfile"

any idea ?



Then define it using Dim....i.e. Dim objFile

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to bolobaboo)
 
 
Post #: 5
 
 RE: Backing up all folder and subfolder recursively , i... - 10/13/2008 6:07:59 AM   
  bolobaboo

 

Posts: 3
Score: 0
Joined: 10/9/2008
Status: offline
Looks like i will not be able to fix above script. Folks ..I need script which does following , if any body has please share with me...
1). It checks file size,date created and if new it would be copied to destination.
2). If same file keep changing then keep latest 2 version by renaming previous files and delete others from destination.
3). It shoulde check recusively all subfolders and folder beneath it then copy same structure to destination.

Thank you


(in reply to bolobaboo)
 
 
Post #: 6
 
 RE: Backing up all folder and subfolder recursively , i... - 10/13/2008 7:51:46 AM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
So you want someone to give you this?  If so, you came to the wrong place....we help and don't write code for people not willing to invest time and effort in learning and doing a lot of the work for themselves.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to bolobaboo)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Backing up all folder and subfolder recursively , i am stuck. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts