Question

I am trying to backup files from a network drive to my C: drive. for the copy I am using:

xcopy "\MY_SERVER_IP\SharedDRIVE\TEST*" "C:\Test_Folder" /D /E /C /I /H /Y

Is there any way I can have the date added onto this and the information not replace but instead compound and have a daily record of changes made to the files but not lose older copies? This will work for copying the most current information, but I need many months of records not just the most current copy.

Any suggestions?

Thanks in advance

Was it helpful?

Solution

This is a way of getting a DateTime string independent of localization:

for /f "tokens=1 delims=." %%i in ('wmic os get localdatetime^|find "."') do set dt=%%i

This is format YYYYMMDDHHMMSScc

You can shorten this string to your needs. for example:

set dt=%dt:~0,8%

will set it to YYYYMMDD only.

set dt=%dt:~0,12%

will set it to YYYYMMDDHHMM

Then you can copy like this:

xcopy "\MY_SERVER_IP\SharedDRIVE\TEST*" "C:\Test_Folder_%dt%" /D /E /C /I /H /Y
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top