|
Answer» I have created a .bat or .cmd file (actually is there any difference?) which (scheduled daily) enables me to copy 5 files to a folder located on a NAS box, for backup purposes. However, with each new backup the existing folder (and its contents) are gone. How can I avoid that by appending the currently backed up folder with (say) a time stamp?
Basically here's what I am trying to accomplish:
First Day COPY path\...\file1 \\NAS\...\FolderName_timestampA\file1 .. ... .... COPY path\...\file5 \\NAS\...\FolderName_timestampA\file5
Second Day COPY path\...\file1 \\NAS\...\FolderName_timestampB\file1 .. ... .... COPY path\...\file5 \\NAS\...\FolderName_timestampB\file5
etc ...
The way I see this HAPPEN is by first creating on the NAS box a folder with the current day and time and ONLY THEN starting a simple copy or xcopy backup from the destination to the newly created folder with the timestamp.
Creating the folders with the current time stamp is marginally out of my abilities.
Doing the copy or xcopy backup, OK this is trivial.
But...
how do I send these 5 files to a different folder every day is totally out of my league.
And the ULTIMATE challenge is how to PACKAGE all this in one .bat or .cmd file.
I am greatly thankful for any of your answers.
Sincerely,
Xwris OnomaTry this Code: [Select]@Echo Off Set d=%date% REM IF THE DATE SEPARATOR IS NOT A "/", THE NEXT LINE CAN BE DELETED Set d=%d:/=% XCopy D:\rootpath\path1\path2\filename.ext \\server\share\folder_%d%\ very nice simple way, but it still shows the day abbreviated. try this
Code: [Select]@echo off for /f "tokens=2-4 delims=/- " %%a in ('date /t') do set DT=%%a%%b%%c XCopy D:\rootpath\path1\path2\filename.ext \\server\share\folder_%dt%\Quote from: BatchFileBasics on September 04, 2009, 08:24:24 PM very nice simple way, but it still shows the day abbreviated. try this
Code: [Select]@echo off for /f "tokens=2-4 delims=/- " %%a in ('date /t') do set dt=%%a%%b%%c XCopy D:\rootpath\path1\path2\filename.ext \\server\share\folder_%dt%\ I also USE token for dated filenaming. but I use rename to change name to my desired naming.
this is good and simple. thanks for sharing it.
|