中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-04 04:17
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » More on creating folders
Printable Version  749 / 2
Floor1 acme Posted 2007-04-13 20:48
中级用户 Posts 98 Credits 238 From 陕西
With guidance from all you experts,
@echo off
for /f "tokens=1-3 delims=\" %%i in ('echo %date:~0,10%') do md d:\%%i%%j%%k
I found a way to create, under a specified path, a folder named with the current date, but after trying many methods I still can't create a folder named with yesterday's date ;), does any expert have a good trick? Please give me some pointers:
Thanks!
Floor2 bjsh Posted 2007-04-13 21:11
银牌会员 Posts 621 Credits 2,000
@echo off & setlocal enabledelayedexpansion
for /f "tokens=1-3 delims=\" %%i in ('echo %date:~0,10%') do set /a yesterday=%%k-1 && md d:\%%i%%j!yesterday!

You'll have to think about the cross-month issue yourself;

Actually, for this kind of cross-month and date problem, vbs is much more powerful
Floor3 acme Posted 2007-04-14 12:05
中级用户 Posts 98 Credits 238 From 陕西
So once it crosses into another month there's no way?
Is there anything more intelligent?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023