Windows 如何从month中获取月份的缩写?

Windows 如何从month中获取月份的缩写?,windows,batch-file,set,Windows,Batch File,Set,我有一个脚本在不同位置的3台服务器上运行,它使用YYYY-MM-DD每晚将JPG移动到一个文件夹,即今天拍摄的图像将在23:55移动到一个名为2014的文件夹、一个名为12的子文件夹和另一个名为31的子文件夹 但是,我想将月份设置为Dec而不是12 我使用的脚本是: @ECHO OFF CLS e: cd \webcam\webadminpan ECHO Checking For any JPG Files DIR /b *.jpg > NUL 2>&1 IF ERROR

我有一个脚本在不同位置的3台服务器上运行,它使用
YYYY-MM-DD
每晚将JPG移动到一个文件夹,即今天拍摄的图像将在23:55移动到一个名为2014的文件夹、一个名为12的子文件夹和另一个名为31的子文件夹

但是,我想将月份设置为Dec而不是12

我使用的脚本是:

@ECHO OFF
CLS

e:
cd \webcam\webadminpan

ECHO Checking For any JPG Files
DIR /b *.jpg > NUL 2>&1
IF ERRORLEVEL 1 GOTO NoFilesFound
ECHO Found Files To Move

SET thisyear=%date:~6,4%
echo I am this year : %thisyear%
SET thismonth=%date:~3,2%
echo I am this month : %thismonth%
SET thisday=%date:~0,2%
echo I am this day : %thisday%

:CheckYearCreate
ECHO Checking to see if year directory %thisyear% exists 
DIR /b "%thisyear%"> NUL 2>&1 
IF ERRORLEVEL 1 GOTO CreateYear 
ECHO Directory %thisyear% must already be present

:CheckMonthCreate
ECHO Checking to see if month directory %thismonth% exists 
DIR /b "%thisyear%\%thismonth%"> NUL 2>&1 
IF ERRORLEVEL 1 GOTO CreateMonth 
ECHO Directory %thisyear%/%thismonth% must already be present

:CheckDayCreate
ECHO Checking to see if day directory %thisday% exists 
DIR /b "%thisyear%\%thismonth%\%thisday%"> NUL 2>&1 
IF ERRORLEVEL 1 GOTO CreateDay 
ECHO Directory %thisyear%/%thismonth%/%thisday% must already be present

:MoveJPGFiles
ECHO Moving JPG Files To "%thisyear%/%thismonth%/%thisday%"
MOVE *.jpg "%thisyear%\%thismonth%\%thisday%"
GOTO TheEnd


:CreateYear
ECHO Making Year %thisyear% Directory
MKDIR "e:\webcam\webadminpan\%thisyear%"
GOTO CheckYearCreate

:CreateMonth
ECHO Making Month %thismonth% Directory
MKDIR "e:\webcam\webadminpan\%thisyear%\%thismonth%"
GOTO CheckMonthCreate

:CreateDay
ECHO Making Day %thisday% Directory
MKDIR "e:\webcam\webadminpan\%thisyear%\%thismonth%\%thisday%"
GOTO CheckDayCreate

:NoFilesFound
ECHO Nothing to Move

:TheEnd
ECHO Finished

Exit /b 0

有谁能建议我如何完成这项任务,并将
本月
设置为短缩写而不是数字?

本月
初始化后尝试此操作:

:: assuming that thismonth is already set by your script.
set thismonth=09

:: clears the leading zeroes
cmd /c exit /b %thismonth%
set c_month=%errorlevel%

:: sets month as a word but not as a digits
for /f "tokens=%c_month%" %%a in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "w_month=%%a"

:: month is set as a word
echo %w_month%
假设您的
月份
有前导零-如果不是这样,请删除前导零。代码用文本替换
月份
中的数值

顺便说一句-你可以
MKDIR
一个目录(或者
MD
-它是一个同义词),然后简单地将
2>nul
附加到行中以抑制“目录已存在”消息。这将为您节省一堆代码

FOR %%a IN ("01 Jan" "02 Feb" "06 Jun" "07 Jul") DO FOR /f "tokens=1,2" %%b IN (%%a) DO IF %month%==%%b SET "month=%%c"