# Faster way to copy missing files

**URL:** https://www.finalbuilder.com/forums/t/faster-way-to-copy-missing-files/1458
**Category:** Discussion
**Created:** [April 5, 2010, 9:39am UTC](https://www.finalbuilder.com/forums/t/faster-way-to-copy-missing-files/1458 "2010-04-05T09:39:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 5, 2010, 9:39am UTC](https://www.finalbuilder.com/forums/t/faster-way-to-copy-missing-files/1458/1 "2010-04-05T09:39:18Z")

</div>

Hopefully you guys can point me to a faster way to copy new/missing files onto other servers if they do not exist in the destination folder's tree.

Brief description:

Hundreds of files are actively copied into the _Source_ folder all day long. This project, on an hourly schedule, deploys files to a QA server and a Staging server. As the number of files has increased, so has the total run time of the project. The project now takes 1.5 hours to run, which is not acceptable because it is supposed to be running on an hourly schedule.

The _Source_ folder is a single folder. Files are only copied into the QA/Staging server if they do not exist in the tree of the _Destination_ folder.

_Destination\Working_   
_Destination\Processed_   
_Destination\Bad_   
_Destination\Scraped_  

To accomplish this, I use the following steps:  
FileSet define [FilesQA] (all destination folders are defined)  
&nbsp;&nbsp; FileSet to Variable [FilesQA] -\> [iFilesQA]  
FileSet define [FilesStaging] (all destination folders are defined)  
&nbsp;&nbsp; FileSet to Variable [FilesStaging] - \> [iFilesStaging]  
FileSet define [FilesSource]  
&nbsp;&nbsp; Iterate FileSet [FilesSource] (iFilesSource as variable)  
&nbsp;&nbsp; Path Manipulation [iFilesSource] (extract filename)  
&nbsp;&nbsp; If [%iFilesSource%] is not in [%iFilesQA%] (xcopy file to destination)  
&nbsp;&nbsp; If [%iFilesSource%] is not in [%iFilesStaging%] (xcopy file to destination)

The _Source_ folder is cleaned up every day so that it only contains the last 7 days of files.

_Source_ currently contains 5,043 files. An average of 30 1mb files are added to _Source_ each hour.

Looking at the logs, the **If [%iFilesSource%] is not in** steps have a combined run time of 1 second if the file already exists on all servers. Multiple that by 5043 and you get 84 minutes just to check the existence of the files.

Is there a better way to do this??

---

<div class="post-metadata">

### Author: ![paulsamways](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/p/e8c25b/32.png) [@paulsamways](https://www.finalbuilder.com/forums/u/paulsamways)
#### Post date: [April 5, 2010, 11:57am UTC](https://www.finalbuilder.com/forums/t/faster-way-to-copy-missing-files/1458/2 "2010-04-05T11:57:21Z")

</div>

Hi,   
  
 Have a look at using the XCopy or Robocopy Mirror actions. Both of these have options to only copy newer files to the destination.   
  
 Regards,   
 Paul.

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [April 6, 2010, 12:38pm UTC](https://www.finalbuilder.com/forums/t/faster-way-to-copy-missing-files/1458/3 "2010-04-06T12:38:29Z")

</div>

> Posted By Paul Samways on 05 Apr 2010 04:57 PM   
> Hi,   
>   
> Have a look at using the XCopy or Robocopy Mirror actions. Both of these have options to only copy newer files to the destination.   
>   
> Regards,   
> Paul.

I use both XCopy and Robocopy exactly how you describe in other projects, but they do not apply in this situation.

 

I only want to copy files FROM _Source_ IF they DO NOT exist in _Destination_ OR any of its subdirectories.

 

So I only want to copy file.xml from _Source_ to _destination\scraped_ if it DOES NOT exist in _destination\scraped_, _destination\processed_, _destination\bad_, or _destination\working_.
