Every so often our company updates forms for 65 different properties which means files get copied to 65 different directories. I've got a script that currently just deletes the Form directory within each property directory and then copies a new directory full of forms (some new some old) to each property.
The script for copying looks like this..
for /d %%a in (\\company-nas\elc\Shared\Sites\*) do xcopy /e /y /i "\\company-nas\elc\Shared\Ops\Forms\Forms Master - ALL\" "%%a\Forms-Master-ALL"
This works but I'm just curious if this is the best approach. The next form update includes 60 updated forms (the names don't change just content within).
Is there any way to grab the 60 forms I need and just copy those without having to replace the entire directory?
Windows BatchWindows Server 2008Windows 7
Last Comment
Vontech615
8/22/2022 - Mon
Gabriel Clifton
With xcopy, the /d switch will only copy files that are newer than the ones currently in the destination.
I can use robocopy and I'm not versed in Powershell at all, although I could tinker with it to figure it out. Gabriel's suggestion would actually work fine I think.
The reason I wrote the originally script using the for command was due to the directories all having different names within the Sites folder. I need something that would go through and execute the copy to all * folders.
Vontech615
ASKER
They are telling me now that they also deleting some files on the reference directory (one to be copied with current updates). So I would also need a second piece to this to remove deleted files in the destinations.
I've decided for this time around to just run my rmdir script and then the copy script. I will probably use Robocopy instead of xcopy in the script but is there a way to create the destination directory since I'm deleting in the first part?
I looked over the syntax but didn't see this option.
Wow, that worked exactly like I wanted it too! With the /s /MIR options I won't have to run the rmdir and won't have to copy all of them over. It updated exactly 60 forms. Awesomesauce.