[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Batch script to copy updated files...

Hi Experts,

I have an issue with scripting and file copying.  Essentially I want to copy a file (leave a copy in the source directory) from a directory of files if it’s been updated, into a new destination folder, much like Robocopy with the /mon does.  The file would retain the same file name after update.

However, in the destination folder it the file will be deleted after imported into an Electronic Content Mgmt (ECM) system.  Robocopy does not like this and will try and put all the files from the source that it copied into the destination folder on the next run.  Any thoughts on a good approach to this?  I’d like to use a batch file with scheduled task.  Here is an example:

Source Folder “A” with many files.
-A file is updated
-Robocopy (or other solution) monitors the update on the run and copies it into Destination Folder “B.”
-File is then imported into ECM solution
-Robocopy should not re-copy the file from the source back into the destination unless further changes have been made.

I chose Robocopy for initial use because of its great Monitoring features.

Thanks for your help!
0
savageje
Asked:
savageje
  • 2
2 Solutions
 
godspropyCommented:
xcopy looks like it might offer some help.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

/m : Copies source files that have their archive file attributes set. Unlike /a, /m  turns off archive file attributes in the files that are specified in the source. For information about how to set the archive file attribute by using attrib, see Related Topics.

http://www.xxcopy.com/xxcopy06.htm

The Archive attribute is set whenever an existing file is either
    overwritten or modified (i.e., renamed or moved to another directory)
    by the file system.  A new file is usually created with the Archive
    attribute set.  The idea is to have a utility or application program
    to take the responsibility of clearing the Archive bit when a
    file is successfully backed up.
0
 
godspropyCommented:
So, basically your scheduled task can use xcopy to copy files with the /m switch. It should only copy files that have are new, have been overwritten or have been modified.
0
 
savagejeAuthor Commented:
Thank you for the suggestion.  I didn't even think to use the attribute switch.  It did exactly what I needed it to.

Thanks!
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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