Re: Daily Backup
- From: Tom <"znjicki[spam]"@yahoo.cmo>
- Date: Thu, 10 Jul 2008 07:53:32 +0200
set /a yest=%somedate% -1 can't be done
i explictily wrote " %day% -1 where day is number -for example 06 not the whole date in your case -- 09/07/2008 - 1 ????
in for loop you cant use delims=. if your date format is dd/mm/yyyy but delims=/
also i don't understand what are yours modifications and why.i cant find the logic explanation.
before scripting go google and learn the basics before you make your script modifications.
DD wrote:
Getting the error Divide by zero error.10 was unexpected at this time..
The folder generated by the application is this format 20080709, will it be any issue.
C:\Data\Batch>backup.bat
C:\Data\Batch>FOR /F "tokens=1* delims= " %A IN ('DATE/T') DO IF "%B" == "" (
SET
Date=%A
) ELSE (SET Date=%B )
C:\Data\Batch>IF "07/09/2008 " == "" (
SET
Date=Wed
) ELSE (SET Date=07/09/2008 )
C:\Data\Batch>for /F "Tokens=1-4 Delims=. " %i in ('echo.07/09/2008 ') do set da
y=%i
C:\Data\Batch>set day=07/09/2008
C:\Data\Batch>for /F "Tokens=1-4 Delims=. " %i in ('echo.07/09/2008 ') do set mo
nth=%j
C:\Data\Batch>set month=
C:\Data\Batch>for /F "Tokens=1-4 Delims=. " %i in ('echo.07/09/2008 ') do set ye
ar=%k
C:\Data\Batch>set year=
C:\Data\Batch>set dt=--07/09/2008 ***today date
C:\Data\Batch>set /A yesterday=07/09/2008 - 1
Divide by zero error.
10 was unexpected at this time.
C:\Data\Batch>if LSS 10 set yesterday=0
C:\Data\Batch>
"Tom" <"znjicki[spam]" wrote:
FOR /F "tokens=1* delims= " %%A IN ('DATE/T') DO IF "%%B"=="" (SET Date=%%A) ELSE (SET Date=%%B)
for /f "Tokens=1-4 Delims=. " %%i in ('echo.%date%') do set day=%%i
for /f "Tokens=1-4 Delims=. " %%i in ('echo.%date%') do set month=%%j
for /f "Tokens=1-4 Delims=. " %%i in ('echo.%date%') do set year=%%k
set dt=%day%-%month%-%year% ***today date
set /A yesterday=%day% - 1
if %yesterday% LSS 10 set yesterday=0%yesterday%
set yesterdate=%yesterday%-%month%-%year% *** yesterday date
xcopy c:\Program Files\Logger\Channel1\%yesterdate% e:\data
----all this in some batch file and schedule it to run
This is example but it doesnt include if it is a leap year or if it is the first day of the month. To do that you must add sevaral different subrutines..
look at http://www.robvanderwoude.com/datetiment.html#Yesterday
DD wrote:Soory, my question may be not clear in my first port.
In windows, how to write a batch to copy yesterday's date folder to anothere directory.
I see a lot of post in Unix but not sure how to do it in windows.
"DD" wrote:
Everyday the program will generate the new folder using the ddmmyyyy format.
I want to backup the folder with yesterday's data using the backup schedule job.
how to create the backup batch file.
@echo off
xcopy c:\Program Files\Logger\Channel 1\ddmmyy e:\data, how to make it so that the batch job know it's yesterday date folder.
- References:
- Re: Daily Backup
- From: Tom
- Re: Daily Backup
- From: DD
- Re: Daily Backup
- Prev by Date: Re: Upgrade Windows 2003 Standard to Enterprise (In-Place upgrade)
- Next by Date: Task Scheduler IGNORES duration
- Previous by thread: Re: Daily Backup
- Next by thread: Re: Daily Backup
- Index(es):
Relevant Pages
|