BATCH - Create a copy of a file with a date & time in the filename

Post date: Sep 22, 2011 11:29:56 AM

This is a handy snippet for creating backups of a file. The backup will get a date and time appended to its file name.

@echo off @For /F "tokens=1,2,3 delims=/ " %%A in ('Date /t') do @( Set datum=%%C%%B%%A ) @For /F "tokens=1,2,3 delims=: " %%A in ('Time /t') do @( Set mintid=%%A_%%B ) copy ..\target\Target.sql ..\target\Target_backup_%datum%_%mintid%.sql"