Page 1 of 1
creating folder
Posted: 16 Dec 2017 06:40
by joe
hi,
can someone please help me.
create a folder based on the current month & year (ie... December 2017, January 2018 and so on)
it should change automatically every month..
thanx in advance
Re: creating folder
Posted: 16 Dec 2017 08:30
by Squashman
This was all from searching the forums and the Internet. The list goes on and on.
Code: Select all
@echo off
REM Get date and time in YYYYMMDDhhmmss format
for /f "tokens=2 delims==." %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "months=01-January;02-February;03-March;04-April;05-May;06-June;07-July;08-August;09-September;10-October;11-November;12-December"
CALL set "months=%%months:*%MM%-=%%"
(set "monthname=%months:;=" & set /p "=%" ) <nul >nul
echo %monthname% %YYYY%
pause
or
Code: Select all
@echo off
setlocal EnableDelayedExpansion
for /f "tokens=2 delims==." %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set m=100
for %%m in (January February March April May June July August September October November December) do (
set /A m+=1
set "month[!m:~-2!]=%%m"
)
set "monthName=!month[%MM%]!"
echo %monthName% %YYYY%
pause
or
Code: Select all
@echo off
for /f "tokens=2 delims==." %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
IF "%MM:~0,1%"=="0" SET "MM=%MM:~1%"
FOR /f "tokens=%MM%" %%G in ("January February March April May June July August September October November December") do set monthname=%%G
echo %monthName% %YYYY%
pause
Re: creating folder
Posted: 16 Dec 2017 08:56
by joe
hi
thank you squashman so kind of you..
have a nice weekend..