Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1681
  • Last Modified:

script to copy files from one folder to another every hour

i am using windows server 2008

i want to run a script at startup that will copy folder a into folder b every hour.

for example:

C:/Folder A  copies to  C:/Documents/Folder B
at the following times:
08:00am
09:00am
10:00am
11:00am
12:00pm
01:00pm  etc.

so that any changes made to C:/Folder A between the hour will be transfered to
C:/Documents/Folder B every hour.

hope this is not too hard to do

thanks
0
webdott
Asked:
webdott
3 Solutions
 
Sekar ChinnakannuSenior EngineerCommented:
You can use robocopy, also check this

 Dim sOriginFolder, sDestinationFolder, sFile, oFSO
 Set oFSO = CreateObject("Scripting.FileSystemObject")
 sOriginFolder = "c:\tp"
 sDestinationFolder = "c:\tp2"
 For Each sFile In oFSO.GetFolder(sOriginFolder).Files
  If Not oFSO.FileExists(sDestinationFolder & "\" & oFSO.GetFileName(sFile)) Then
   oFSO.GetFile(sFile).Copy sDestinationFolder & "\" & oFSO.GetFileName(sFile),True
   WScript.Echo "Copying : " & Chr(34) & oFSO.GetFileName(sFile) & Chr(34) & " to " & sDestinationFolder
  End If
 Next

http://www.visualbasicscript.com/Copy-Files-Using-VbScript-m43169.aspx
0
 
ReneGeCommented:
Whay not just adding your command line as a scheduled task that will be triggered every hour?
0
 
ReneGeCommented:
Or if you absolutly want a script, here is an alternative to sekarc4u's solution

@ECHO OFF
:Home
ECHO %Date% Time% Copying in progress
C:/Folder A  copies to  C:/Documents/Folder B
ECHO %Date% Time% Copy completed
CHOICE /D Y /T 3600 >NUL
GOTO Home
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
webdottAuthor Commented:
ReneGe

does that script work on every hour? or just once manually?

not sure how to do the task scheduler.
i can see where to add the timer, but the action requites to start a program, send email, but not
copy folder contents to folder contents

thanks
0
 
dpearsonCommented:
The way to use the task scheduler is to create a little batch file that does the copying (like the one ReneGe suggested).  Then set the action of the task to be to run this batch file (that's the "program" you're looking for).  Now you can setup the schedule and run it whenever you want - e.g. ever hour.

Doug
0
 
ReneGeCommented:
Yes, it will run at every 60minuts (3600 seconds) from the moment you start it.
However, I use Task scheduler to do this kind of tasks.
0
 
ReneGeCommented:
W2008 choild have the command "choice" by defailt. To confirm you have it, open a command prompt and type "choice". If you get a "YN" response, you all good.
0
 
webdottAuthor Commented:
thanks that works
0
 
ReneGeCommented:
Glad I could help
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now