Hello Folks,
Have a small problem that I'm hoping I could get some assistance with. I currently have a batch file (if memory serves, it seems I originally obtained the idea from this site) that takes the date and adds it to an archive file that's created on a daily basis. This works fine when the regional short date format in Windows is setup for M/d/yyyy. However, we have another location which is using the short date format of dd-MMM-yy in which case the same batch file will not work. I've tried adjusting the date variables in the existing batch file, but I'm not getting anywhere.
Is it possible someone might be able to tell me which settings I need to adjust to accommodate the other date format of dd-MMM-yy so the batch file could do it's thing?
Existing file:
@echo off
:: setting MM to equal the current numeric month
set MM=%date:~4,2%
:: putting all the possible months into a variable which will be parsed in the for loop
set month_text="01 JAN" "02 FEB" "03 MAR" "04 APR" "05 MAY" "06 JUN" "07 JUL" "08 AUG" "09 SEP" "10 OCT" "11 NOV" "12 DEC"
:: for loop is parsing the month_text variable and using the find command with the numeric month to set the month variable
for %%I in (%month_text%) do echo %%I |find "%MM%" &&set MM=%%~I
:: Need to remove the Number and space
echo Date: %date%
echo Today: %date:~7,2% %MM:~3% %date:~10,4%
SET Month=%DATE:~4,2%
if %Month%==01 set Month=JAN
if %Month%==02 set Month=FEB
if %Month%==03 set Month=MAR
if %Month%==04 set Month=APR
if %Month%==05 set Month=MAY
if %Month%==06 set Month=JUN
if %Month%==07 set Month=JUL
if %Month%==08 set Month=AUG
if %Month%==09 set Month=SEP
if %Month%==10 set Month=OCT
if %Month%==11 set Month=NOV
if %Month%==12 set Month=DEC
echo %Month%
@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
Set Day=%%A
Set Month=%%B
Set Year=%%C
Set All=%date:~7,2% %MM:~3% %%C
)
ECHO Compressing Daily Inventory/Receiving Files and Powering Off
ECHO off
7z a -t7z "Warehouse 7C - %ALL%.7z" -x!*.7z -mx9 -mmt
shutdown /s
In all file names, I wish for the date to appear as DD MMM YYYY [ie: 02 NOV 2014]
Thanks so much,
Ken