Batch common to create folder using month year name

@echo off

for /f “tokens=1-4 delims=/ ” %%i in (“%date%”) do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
set datestr=%month%_%day%_%year%
echo datestr is %datestr%

setlocal EnableDelayedExpansion
set months[“01”]=January
set months[“02”]=February
set months[“03”]=March
set months[“04”]=April
set months[“05”]=May
set months[“06”]=June
set months[“07”]=July
set months[“08”]=August
set months[“09”]=September
set months[“10”]=October
set months[“11”]=November
set months[“12”]=December

SET dirname=\\host\common\folder name with spaces\!months[“%month%”]!%year%
echo “%dirname%” >>d:\dts\log.txt
mkdir “%dirname%”
move D:\dts\incoming\* “%dirname%”
echo “exit code %errorlevel%” >>d:\dts\log.txt

Leave a Reply

Your email address will not be published. Required fields are marked *