Skip to content

Copy file and keep duplicate

 

About:

Copy files from source to destination and keep duplicate with time stamp

 

 

Steps:

  • Create a BAT file and copy code below

 

 

Code:

@echo off

for /f “tokens=2 delims==” %%a in (‘wmic OS Get localdatetime /value’) do set “dt=%%a”

set “YY=%dt:~2,2%” & set “YYYY=%dt:~0,4%” & set “MM=%dt:~4,2%” & set “DD=%dt:~6,2%”

set “HH=%dt:~8,2%” & set “Min=%dt:~10,2%” & set “Sec=%dt:~12,2%” & set “MS=%dt:~15,3%”

set “datestamp=%YYYY%%MM%%DD%” & set “timestamp=%HH%%Min%%Sec%” & set “fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%-%MS%”

echo datestamp: “%datestamp%”

echo timestamp: “%timestamp%”

echo fullstamp: “%fullstamp%”

echo f| Xcopy /S /C /Y “source” “destination”