1
我目前的代碼對今天的修改日期工作正常,但是現在我想要我的代碼複製第一天的數據以及今天的數據。Xcopy複製第-1天的數據
@ECHO OFF
FOR /F "tokens=2 delims= " %%V IN ("%DATE%") DO SET TDY=%%V
xcopy /y "DATA_PATH" "LOCAL_SYSTEM" /d:%TDY%
SET TDY=
我目前的代碼對今天的修改日期工作正常,但是現在我想要我的代碼複製第一天的數據以及今天的數據。Xcopy複製第-1天的數據
@ECHO OFF
FOR /F "tokens=2 delims= " %%V IN ("%DATE%") DO SET TDY=%%V
xcopy /y "DATA_PATH" "LOCAL_SYSTEM" /d:%TDY%
SET TDY=
一種方法使用BAT/VBS解決方案,使昨天的日期:
Yesterday.bat
@echo off
>yesterday.vbs echo wscript.echo DateAdd("d", -1, Date(^)^)
for /f "delims=" %%a in ('cscript /nologo yesterday.vbs') do set "$yesterday=%%a"
Echo Yesterday'Date is ==^> %$Yesterday%
如果你想通過-
例如直接替換/
字符:
Yesterday.bat
@echo off
>yesterday.vbs echo wscript.echo replace((DateAdd("d", -1, Date(^)^)^),"/","-"^)
for /f "delims=" %%a in ('cscript /nologo yesterday.vbs') do set "$yesterday=%%a"
Echo Yesterday'Date is ==^> %$Yesterday%
你需要下載datex.exe:
For /f %%a in ('DateX -o -1 -f yyyymmdd') do Set "PreDate=%%a"
DATEX用法:
4:12:56.76 c:\>datex /?
DateX 2.7 - (C) 2004-2010 by Bill Stewart ([email protected])
Usage: datex [-d date] [-f format] [-i num] [-o offset] [-t]
-d Specifies a date.
-f Specifies the format for the date.
-i Output the date represented by the specified number (inverse of -t).
-o Specify a number-of-days difference.
-t Output the date as a number for comparison purposes.
Without arguments, DateX prints the current date and time.
使用[搜索功能](http://stackoverflow.com/search?q= %5Bbatch-file%5D + get + yesterdaydays + date) – Stephan
感謝Stephan的回覆.....但是我對xcopy很陌生,對於搜索功能不知道 – Ishu
這不是'xcopy'issue,你只需要得到昨天的日期。點擊我的第一條評論中的藍色字詞「搜索功能」。它直接引導你到相關的線程。你會發現很多不同的方法來計算它;選擇一個,最適合您的需求。當然,如果你遇到麻煩,你可以再問一次。 – Stephan