最近几天我一直在寻找这个问题的答案。有很多关于全年批量文件夹创建的答案,但不够具体,所以我非常感谢答案。
所以我想要这样的文件夹结构,如下所示
2017 (for example main folder for year 2017)
01_JAN....12_DEC (subfolders with names of month )
01JAN/01_01_SUN, 02_01_MON, 03_01_TUE...etc (subsub folders with week day name at the end)
另外,如果可能的话,也可以在这里包含周数,尽管我对工作日感到满意,即
01JAN/01_01_SUN-52, 02_01_MON-01, 03_01_TUE-01...09_01_MON-02 etc with weekdays starts with monday
我计划在条形码生产自动化项目中使用它
谢谢你!
附注
我得到的最接近的是我设法找到的这个例子如何编写批处理脚本来生成每月、每天和每年的文件夹? https://superuser.com/questions/483045/how-do-i-write-a-batch-script-to-generate-folders-for-each-month-day-and-year
这个批处理文件做你想做的事。
EDIT:我添加了以下修改:
1-年份是从键盘读取的,而不是从参数中获取的。
2- 在放置批处理文件的同一文件夹中创建年份文件夹。
3-修复了“第53周”中的一个小错误。
@echo off
setlocal EnableDelayedExpansion
set /P "year=Enter desired year: "
rem Select the base folder
cd "%~P0"
rem Initialize all variables
set i=0
for %%a in (Jan:31 Feb:28 Mar:31 Apr:30 May:31 Jun:30 Jul:31 Aug:31 Sep:30 Oct:31 Nov:30 Dec:31) do (
for /F "tokens=1,2 delims=:" %%m in ("%%a") do (
set /A i+=1
set "month[!i!]=%%m"
set "dpm[!i!]=%%n"
)
)
set /A "dpm[2]+=^!(year%%4), d=((year+4799)*1461/4-(year+4899)/100*3/4+1)%%7*3, rot=^!d+((d-15)>>31)+1, week=101+51*rot"
if %d% equ 3 set "week=100"
set "dow=SunMonTueWedThuFriSat"
set "dow=!dow:~%d%!!dow:~0,%d%!"
rem Create the folders
md %year%
cd %year%
for /L %%m in (1,1,12) do (
set "m=0%%m"
set "m=!m:~-2!"
md !m!_!month[%%m]!
cd !m!_!month[%%m]!
for /L %%d in (1,1,!dpm[%%m]!) do (
set "d=0%%d"
if "!dow:~0,3!" equ "Mon" set /A week+=1 & if !week!!rot! equ 1531 set "week=101"
md !d:~-2!_!m!_!dow:~0,3!-!week:~1!
set "dow=!dow:~3!!dow:~0,3!"
)
cd ..
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)