Script to copy files not in progress of being copied

Discussion in 'Scripting' started by Lars, Aug 27, 2008.

  1. Lars

    Lars Guest

    I have a batchfile that copies files in a directory to another directory.
    Files are being copied to the source directory and I don´t want the copy to
    include files in progress of being copied. How do I do this?

    Regards Lars
    Lars, Aug 27, 2008
    1. Advertisements

  2. Depending on the method used for copying, files that are
    being copied will be locked and won't be touched by the
    second copy process.

    It might help if you were a little more specific and gave
    full details about the two concurrent copy processes.
    Pegasus \(MVP\), Aug 27, 2008
    1. Advertisements

  3. Lars

    Lars Guest

    Thanx for you answer Pegasus,

    We have a scanner that creates a PDF in an Incoming folder.
    A script runs in the Incoming folder that splits multipage PDF files
    to multiple files in an Outgoing folder and deletes the original file in
    the Incoming folder. This works great until there´s a file in progress
    being copied/created in the Incoming folder. To avoid these problems
    I´m gonna copy the files in the Incoming folder to a Working folder and
    run the script in thata folder instead. I just need the copy to exclude
    any files being transfered by the scanner.

    Regards Lars
    Lars, Aug 27, 2008
  4. Perhaps a copy process with an inbuilt "wait" function would do the trick:

    sSourceName = "d:\temp"
    sTargetName = "c:\"
    iDelay = 5 'Minutes

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    For Each oFile In objFSO.GetFolder(sSourceName).Files
    If DateDiff("n", oFile.DateLastModified, Now) > iDelay Then
    oFile.Copy sTargetName
    End If
    Pegasus \(MVP\), Aug 27, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.