1.

Solve : Batch filebackup to date stamped folder?

Answer»

I am doing a project where i have to create a menu system to backup files to a SPECIFIC location, backup files that have been created since last backup and offer a restore files option. The only problem i have is how to get the program to copy all files from a specific folder to a date stamped folder. Any help appreciatedplease show your local date format setting

here's mine for example

Code: [Select]C:\>echo %date%
05/10/2009My date setting is the same as yoursuse string slicing to get the YYYY MM and DD parts out of %date% and the mkdir command to create the folder NAMED as you want

slice a string thus %string:offset,length% offset is the offset from the start (0 is 1st CHAR) and length is the no of chars.

THis should give you the idea, and also something to build on...

Code: [Select]set dd=%date:~0,2%
set mm=%date:~3,2%
set yyyy=%date:~6,4%
set newfolder=%yyyy%-%mm%-%dd%
if not EXIST %newfolder% mkdir %newfolder%
copy myfolder\*.* %newfolder%



Discussion

No Comment Found