Copy Files to Multipe Locations with Robocopy

1. Prepare a destination list with one item each line and save it to the same location as the .bat file;
2.Save the following file as bat file to c:\jobs;




for /f "usebackq tokens=*" %%T in ("FolderList.txt") do (
robocopy c:\temp\myfiles_src\ \\mydestination\%%T\myfolder\ /s /LOG+:C:\jobs\log\%date:~-4,4%%date:~-10,2%%date:~-7,2%_log.txt 
)



Execute this bat file manually or through a scheduled job.

Advertisements

How to Get Non Weekend Dates

Give you a given date, how to find out whether it is a weekend date. You may start with with DATEPART(dw, GETDATE()). Due to the different environment with SET LANGUAGE, you may have different SETFIRST value.
But if you can use a calculation to include this datefirst difference, you can get a solution that works for all environments.
(DATEPART(dw, getdate())+@@DATEFIRST)%7 not in (0,1).

An example to use this:

Select * from yourtable where (DATEPART(dw, dtColumn)+@@DATEFIRST)%7>1