Solved

Moving files upon creation

Posted on 2007-04-09
2
167 Views
Last Modified: 2011-09-20
We have a app that drops files a folder for processing.
I am looking to dupliate these files in another folder for redundancy.  We do have backups but have trouble with the files being opened and would like to add this method to increase the chance for successful recovery in case of problem.
Can we write a script to watch a folder for new fils and copy them to another folder on the server?
0
Comment
Question by:sher19
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18880243
This script will do just that...set it up to launch on startup (or logon) and it'll monitor the folder - the example below uses c:\scripts (listed as c:\\\\scripts)
It's set to poll every 10 seconds...adjust as necessary.

'WatchFolder.vbs
Dim objFSO: Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objWMI: Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
strTarget = "\\Servername\share\backup\"
Set colEvents = objWMI.ExecNotificationQuery _
    ("SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE " _
        & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
            & "TargetInstance.GroupComponent= " _
                & "'Win32_Directory.Name=""c:\\\\scripts""'")
Do
    Set objEvent = colEvents.NextEvent
    strNewFile = Replace(Mid(objEvent.TargetInstance.PartComponent, InStr(1, objEvent.TargetInstance.PartComponent, Chr(34))), "\\", "\")
    objFSO.CopyFile strNewFile, strTarget
Loop
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18880288
Happy to help - thanx! :^)
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Logon script fails 23 61
batch file or script 4 50
Select SamAccountName - powershell script 2 19
Hta File displays dynamic File names 4 50
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question