今天和明天的批处理文件时间戳

Batch File timestamp for today and tomorrow

我正在尝试创建一个批处理文件来创建一个以明天的日期命名的新文件夹,但我还需要它来从具有今天日期的文件夹中获取文件。我的代码是这样写的,所以它只在我输入 %mm%%dd%%yy% 的明天日期之前设置它。我需要帮助编辑它,以便它以某种方式抓住两者。这是我的代码

@echo off

setlocal enableextensions disabledelayedexpansion

rem Retrieve data
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" 
set "YY=%dt:~2,2%" 
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%"
set "Min=%dt:~10,2%"
set "Sec=%dt:~12,2%"

rem Remove padding from date elements and increase day
set /a "y=%YYYY%", "m=100%MM% %% 100", "d=(100%DD% %% 100)+1" 
rem Calculate month length
set /a "ml=30+((m+m/8) %% 2)" & if %m% equ 2 set /a "ml=ml-2+(3-y %% 4)/3-(99-y %% 100)/99+(399-y %% 400)/399"
rem Adjust day / month / year for tomorrow date
if %d% gtr %ml% set /a "d=1", "m=(m %% 12)+1", "y+=(%m%/12)"

rem Pad date elements and translate again to original variables
set /a "m+=100", "d+=100"
set "YYYY=%y%"
set "YY=%y:~-2%"
set "MM=%m:~-2%"
set "DD=%d:~-2%"

echo Tomorrow: %YYYY% / %MM% / %DD%

mkdir "C:\Users\name\Desktop\DNFB %mm%%dd%%yy%\"
mkdir "C:\Users\name\Desktop\DNFB %mm%%dd%%yy%\DNFB"

xcopy /s "C:\Users\name\Desktop\"DNFB %mm%%dd%%yy%"\file*.xls" "C:\Users\name\Desktop\DNFB %mm%%dd%%yy%\"

xcopy /s "C:\Users\name\Desktop\"DNFB %mm%%dd%%yy%"(今天)\file*.xls" "C:\Users\name\Desktop\DNFB %mm%%dd%%yy%(TOMORROW)\" - 从标记为 "DNFB 010815" 的文件夹中抓取文件并将其粘贴到文件夹 "DNFB 010915"(明天)

这可能吗?还是太矛盾了。谢谢

你有逻辑。使用更多变量

@echo off

    setlocal enableextensions disabledelayedexpansion

    for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" 
    set "td.YY=%dt:~2,2%" 
    set "td.YYYY=%dt:~0,4%"
    set "td.MM=%dt:~4,2%"
    set "td.DD=%dt:~6,2%"

    rem Remove padding from date elements and increase day
    set /a "y=%td.YYYY%", "m=100%td.MM% %% 100", "d=(100%td.DD% %% 100)+1" 
    rem Calculate month length
    set /a "ml=30+((m+m/8) %% 2)" & if %m% equ 2 set /a "ml=ml-2+(3-y %% 4)/3-(99-y %% 100)/99+(399-y %% 400)/399"
    rem Adjust day / month / year for tomorrow date
    if %d% gtr %ml% set /a "d=1", "m=(m %% 12)+1", "y+=(%m%/12)"

    rem Pad date elements and set tomorrow variables
    set /a "m+=100", "d+=100"

    set "tm.YYYY=%y%"
    set "tm.YY=%y:~-2%"
    set "tm.MM=%m:~-2%"
    set "tm.DD=%d:~-2%"

    echo Today   : %td.YYYY% / %td.MM% / %td.DD%
    echo Tomorrow: %tm.YYYY% / %tm.MM% / %tm.DD%