I want to use the month name in the file name. i am exporting the data from sql server the name of the file should use the system date if the month is 3 three then it should print the file name as febact,if the month is 4 then it should print marchact.
Thanks, Ravi.
You have not provided the format of your file name. The Batch file below just converts the month of current date:
@echo off
setlocal EnableDelayedExpansion
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
)
rem Change tokens=2 for DD/MM/YYYY date format
for /F "tokens=1 delims=/" %%m in ("%date%") do (
set monthName=!month[%%m]!
)
echo %monthName%
If you want month name have constant length (ie: 3 letters):
@echo off
setlocal EnableDelayedExpansion
for /F "tokens=1 delims=/" %%m in ("%date%") do (
set /A "m=(1%%m%%100-1)*3"
)
set month=JanFebMarAprMayJunJulAugSepOctNovDec
set monthName=!month:~%m%,3!
echo %monthName%
Antonio
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With