1.

Solve : Help: Bat file will not create AlfaMonth August?

Answer»

I have been using the bat file below to create folders based on tomorrows date, however since begining of August the bat file fails to to created AlfaMonth August

The error that appear is: 8" was unexpected at this time

Can anyone help me, I need to know why this is happening

Code is:


@echo off
cls


: This file should be saved as .bat, and when run will create a copy of the file to the given DESTINATION as per code
:: Create/run vbs file (extracts date components) & set variables..

:: Tommorrows date is acheived by adding to Newdate ... (Date()+1)
set vb=%temp%\newdate.vbs
echo Newdate = (Date()+1) > %vb%
echo Yyyy = DatePart("YYYY", Newdate) >> %vb%
echo Mm = DatePart("M" , Newdate) >> %vb%
echo Dd = DatePart("D" , Newdate) >> %vb%
echo Wd = DatePart("WW" , Newdate) >> %vb%
echo Wn = DatePart("Y" , Newdate) >> %vb%
echo Ww = datepart("W" , Newdate) >> %vb%

echo Wscript.Echo Yyyy^&" "^&Mm^&" "^&Dd^&" "^&Wd^&" "^&Ww^&" "^&Wn >> %vb%

FOR /F "tokens=1-6 delims= " %%A in ('cscript //nologo %vb%') do (
set Year=%%A
set Month=%%B
set Day=%%C
set Week#=%%D
set Weekday#=%%E
set Day#=%%F
)
del %vb%

If %Month% lss 10 set Month=0%Month%
if %Day% lss 10 set Day=0%Day%
set Today=%Day%%Month%%Year%
set Tomorrow=%Today%+1
for /f "Tokens=%Month%" %%A in (
"January February March April May June July August SEPTEMBER October November December") do (
set Alfamonth=%%A
)


set Filename="C:\Folder Creation\Tomorrow"
echo Source path\
echo filename = %Filename%
echo.
echo Today = %Today%
echo Year = %Year%
echo Alpha month = %Alfamonth%
echo Day=%Day%
echo Month=%Month%


md %FileName%\%Year%\%Alfamonth%\%Today%
md %FileName%\%Year%\%Alfamonth%\%Today%\sample%Day%%Month%"09"
md %FileName%\%Year%\%Alfamonth%\%Today%\sample%Day%%Month%"09"\Loadfolder
You have set the month to 08 (zero eight). When the For command encounters a number beginning with zero it considers it to be Octal (base eight) therefore 08 is an invalid number. The stupid thing doesn't give an error which indicates this except the one you noted.

Suggest you move these LINES Code: [SELECT]If %Month% lss 10 set Month=0%Month%
if %Day% lss 10 set Day=0%Day%
set Today=%Day%%Month%%Year%
set Tomorrow=%Today%+1 so that they're immediately after the For loop.

If you have permissions to download/install a small utility, Doff might save you a lot of coding. See this FAQ.

Good luck. Perfect....

Moving these lines seems to have WORKED great

Thanks Dusty



Discussion

No Comment Found