ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Task Scheduler or VBA to simple copy periodically folders contents toexternal drive (https://www.excelbanter.com/excel-programming/440304-task-scheduler-vba-simple-copy-periodically-folders-contents-toexternal-drive.html)

u473

Task Scheduler or VBA to simple copy periodically folders contents toexternal drive
 
I need to copy periodically all files (without any other data
manipulation)
from folders W, X, Y on Drive C to folder Z on Drive D.
Any existing files would ge ovewritten without prompting.
Is it more convenient to process this through Windows Task Scheduler
or through VBA ?

Help appreciated,

J.P.

Chip Pearson

Task Scheduler or VBA to simple copy periodically folders contents to external drive
 
If you need to work only with files, not subfolders, you can use code
like the following:


Sub AAA()
Dim FromFolders As Variant
Dim ToFolder As String
Dim N As Long
Dim FName As String
FromFolders = Array("C:\Test", "C:\Test2")
ToFolder = "D:\Z"
Application.DisplayAlerts = False
For N = LBound(FromFolders) To UBound(FromFolders)
ChDrive FromFolders(N)
ChDir FromFolders(N)
FName = Dir("*.*", vbNormal)
Do Until FName = vbNullString
On Error Resume Next
Kill ToFolder & "\" & FName
On Error GoTo 0
Name FName As ToFolder & "\" & FName
FName = Dir()
Loop
Next N
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com





On Fri, 5 Mar 2010 13:52:56 -0800 (PST), u473 wrote:

I need to copy periodically all files (without any other data
manipulation)
from folders W, X, Y on Drive C to folder Z on Drive D.
Any existing files would ge ovewritten without prompting.
Is it more convenient to process this through Windows Task Scheduler
or through VBA ?

Help appreciated,

J.P.



All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com