#1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Backing Up

Hi I received this code from Bob Phillips and it does what I want except it
copies everything I want to the "I drive" it makes a folder with today's
date. What I need it to do is actually copy all the items into the
directory with today's date.



'---------------------------------------------------------------------------
Sub CopyFolder()
'---------------------------------------------------------------------------
Dim oFSO As Object
Dim sFolder As String

Set oFSO = CreateObject("Scripting.FileSystemObject")
sFolder = "I:\backup\"
If Not oFSO.FolderExists(sFolder) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
If Not oFSO.FolderExists(sFolder & Format(Date, "yyyy-mm-dd")) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
oFSO.CopyFolder "C:\idsc\*", sFolder & "\"
Set oFSO = Nothing
End Sub


Thanks again

Greg


  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,272
Default Backing Up

Greg,

Here is a variation. It does go into sub-directories though.

'---------------------------------------------------------------------------
Sub CopyFolder()
'---------------------------------------------------------------------------
Dim oFSO As Object
Dim sFolder As String
Dim oFolder As Object
Dim oFile As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")
sFolder = "I:\Backup\"
If Not oFSO.FolderExists(sFolder) Then
MkDir sFolder
End If
If Not oFSO.FolderExists(sFolder & Format(Date, "yyyy-mm-dd")) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
Set oFolder = oFSO.getfolder("C:\idsc\")
For Each oFile In oFolder.Files
If Int(oFile.DateLastModified) = Date Then
oFile.Copy sFolder & Format(Date, "yyyy-mm-dd") & "\" &
oFile.Name
End If
Next oFile

Set oFile = Nothing
Set oFolder = Nothing
Set oFSO = Nothing
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Hi I received this code from Bob Phillips and it does what I want except

it
copies everything I want to the "I drive" it makes a folder with today's
date. What I need it to do is actually copy all the items into the
directory with today's date.




'---------------------------------------------------------------------------
Sub CopyFolder()

'---------------------------------------------------------------------------
Dim oFSO As Object
Dim sFolder As String

Set oFSO = CreateObject("Scripting.FileSystemObject")
sFolder = "I:\backup\"
If Not oFSO.FolderExists(sFolder) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
If Not oFSO.FolderExists(sFolder & Format(Date, "yyyy-mm-dd")) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
oFSO.CopyFolder "C:\idsc\*", sFolder & "\"
Set oFSO = Nothing
End Sub


Thanks again

Greg




  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Backing Up

Sorry Bob or who ever can give me advice,

How can I get it to make a folder called e.g. 04/03/2005 instead of having
a new directory where it includes the date in it. I was hoping to have the
date incorporated into the name so I know when it was backed up.

'---------------------------------------------------------------------------
Sub CopyFolder()
'---------------------------------------------------------------------------
Dim oFSO As Object
Dim sFolder As String
Dim oFolder As Object
Dim oFile As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")
sFolder = "I:\Backup\"
If Not oFSO.FolderExists(sFolder) Then
MkDir sFolder
End If
If Not oFSO.FolderExists(sFolder & Format(Date, "yyyy-mm-dd")) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
Set oFolder = oFSO.getfolder("C:\idsc\")
For Each oFile In oFolder.Files
If Int(oFile.DateLastModified) = Date Then
oFile.Copy sFolder & Format(Date, "yyyy-mm-dd") & "\" &
oFile.Name
End If
Next oFile

Set oFile = Nothing
Set oFolder = Nothing
Set oFSO = Nothing
End Sub


Thanks again

Greg


  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,272
Default Backing Up

This creates a folder with today's date under I:\backup.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Sorry Bob or who ever can give me advice,

How can I get it to make a folder called e.g. 04/03/2005 instead of

having
a new directory where it includes the date in it. I was hoping to have

the
date incorporated into the name so I know when it was backed up.


'---------------------------------------------------------------------------
Sub CopyFolder()

'---------------------------------------------------------------------------
Dim oFSO As Object
Dim sFolder As String
Dim oFolder As Object
Dim oFile As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")
sFolder = "I:\Backup\"
If Not oFSO.FolderExists(sFolder) Then
MkDir sFolder
End If
If Not oFSO.FolderExists(sFolder & Format(Date, "yyyy-mm-dd")) Then
MkDir sFolder & Format(Date, "yyyy-mm-dd")
End If
Set oFolder = oFSO.getfolder("C:\idsc\")
For Each oFile In oFolder.Files
If Int(oFile.DateLastModified) = Date Then
oFile.Copy sFolder & Format(Date, "yyyy-mm-dd") & "\" &
oFile.Name
End If
Next oFile

Set oFile = Nothing
Set oFolder = Nothing
Set oFSO = Nothing
End Sub


Thanks again

Greg




  #5   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Backing Up

Yes it does everything it copies the 4 folders like it should, but, is it
possible to get it to copy all the other folder into the newly created date
folder?

Thanks you again for the advice

Greg




  #6   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Backing Up

Sorry I wasnt thinking, it does exactly what I want please disregard last
post


Thanks for all the help

Greg


  #7   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,272
Default Backing Up

Let's make absolutely sure I understand, because I have gotten confused by
this thread so far.

If you have a folder, with sub-folders, do you want to copy all files, in
the folder and the sub-folder, into a new directory I:\backup\04/03/2005,
but not retaining the sub-folder hierarchy.

C:\dsc
myFile.xls
<sub-gfolder1
myFile2.xls

becomes

i:\backup\04/03/2005
myFile.xls
myFile2.xls

If this is correct, what happens if you have myFile,.xls in the folder, and
also in one or more sub-folders?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Yes it does everything it copies the 4 folders like it should, but, is it
possible to get it to copy all the other folder into the newly created

date
folder?

Thanks you again for the advice

Greg




  #8   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Backing Up

I think I have confused myself too much, I am trying too hard to get this
working perfect. I forgot all i need to do is save the folder as a backup.
I did not need the date. I am very sorry for wasting your time.

Thanks once again

Greg


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
backing up joesf16 Excel Discussion (Misc queries) 4 September 16th 07 01:15 PM
Backing Up Greg B Excel Discussion (Misc queries) 7 March 4th 05 03:45 PM
Backing Up Greg B Excel Worksheet Functions 7 March 4th 05 03:45 PM
Backing up my folders Greg B[_4_] Excel Programming 2 March 3rd 05 10:03 AM
Backing up IE Favorites Spammastergrand Excel Programming 3 February 19th 05 11:42 PM


All times are GMT +1. The time now is 09:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"