Announcement

Collapse
No announcement yet.

Automate file duplication

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automate file duplication

    Hello Team,

    I wonder if one of us can give me an idea on how to pursued this method.

    Here is my scenario.
    1. User execute the client app.
    2. The client app automatically send user file to a temp folder to the server.
    3. Server app execute the temp folder then automatically delete the temp file.

    Here is what I would like to do.
    I want to make a copy of the file in temp folder before server delete them automaically.
    How do I write a some kind of scripts or batch file to trigger that? I want temp folder to trigger the batch file if there is something in the temp folder.

    Edit: I've found a program that can copy the file by interval, but I want it to monitor the folder if there is file in the folder then trigger the copy.
    Thanks,
    HN
    Attached Files
    Last edited by Humannetwork; 5th February 2011, 04:45.

  • #2
    Re: Automate file duplication

    Would it be possible to configure the server application to make a copy of the file? Couldn't you just send the file to two different locations?

    If both scenarios are no good, use System.Io.FileSystemWatcher on the server end to monitor the directory. Powershell makes this easy enough.

    -vP

    Comment


    • #3
      Re: Automate file duplication

      Robocopy can be set to monitoring mode which scan a source folder for new files or file changes and then copies them to a destination folder. You can set the monitoring interval to whatever you like. And it's free.
      A recent poll suggests that 6 out of 7 dwarfs are not happy

      Comment


      • #4
        Re: Automate file duplication

        Von,

        The first 2 scenarios won't work for me. I like the System.Io.FileSystemWatcher with Powershell. Do you know if where is a sample code or template somewhere that I can use?
        Basiclly what Im trying to accomplish is if anything drop into c:\temp I want to make a copy to C:\Temp2

        Thanks,
        HN



        Originally posted by vonPryz View Post
        Would it be possible to configure the server application to make a copy of the file? Couldn't you just send the file to two different locations?

        If both scenarios are no good, use System.Io.FileSystemWatcher on the server end to monitor the directory. Powershell makes this easy enough.

        -vP
        Last edited by Humannetwork; 5th February 2011, 23:25.

        Comment


        • #5
          Re: Automate file duplication

          Try to work from here:

          Code:
          $fsw = New-Object System.IO.FileSystemWatcher "C:\temp"
          $event = Register-ObjectEvent -InputObject $fsw -eventName "Changed" -action {
              write-host ("{0} {1} {2}" -f [datetime]::now, $($event.SourceEventArgs.ChangeType), $($event.SourceEventArgs.FullPath))
          }
          Run the script from a Powershell session and touch a file in c:\temp to see what happens.

          -vP

          Comment

          Working...
          X