I need another batch file!

Associate
Joined
22 Mar 2005
Posts
348
Location
Southampton
Hi guys,
Got some great help on here last time, so here goes with this request.

I'm going to create a scheduled task (weekly) that backs up a specific file by copying it to same directory and appending the date to it's filename.

Simple for you guys I'm sure - I just can't do batch commands!

Thanks :)
 
Hi try this

copy "c:\filename.doc" "c:\filename%date:/=%.doc"

replace the filename and .doc with the filename and extention, don't forget the full path to the file

fliP.
 
Code:
::date code

   FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :s_fixdate %%G %%H %%I %%J)
   goto :s_print_the_date
   
   :s_fixdate
   if "%1:~0,1%" GTR "9" shift
   FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
       set %%G=%1&set %%H=%2&set %%I=%3)
   goto :eof

   :s_print_the_date

   ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%
::date code

set currdate=%yy%-%mm%-%dd%

[b]echo %currdate%[/b] (remove this bit, this just confirms that it works...)
then do copy "c:\files.doc" "d:\files %currdate%.doc"



that code above lets you choose what 'currdate' is.. only edit the set currdate= line
 
Back
Top Bottom