Solved Crete a folder with month as name on every first of month

June 1, 2012 at 03:45:34
Specs: Windows XP
How can I Crete a folder with month as name on every first of month, i have another script tht create a folder with date every day. i want to write other code to create folder with month as name in the same batch..
the batch runs daily when i start my PC. Both are doing great when runs separately.
i think there i am missing some CMD code.

:How can i check today is first day of month?
and the run code?

can anyone help ???


See More: Crete a folder with month as name on every first of month

Report •

#1
June 1, 2012 at 21:05:45
✔ Best Answer
You failed to post your existing code or your date format. The following script should extract the date and create a new folder on the 1st of each month. It is untested.

@echo off
cls
setlocal enabledelayedexpansion

:: Extract current month/date using VB script.

set fil=%temp%\fil.vbs

(
echo Newdate = Date
echo   Mm = DatePart("M"   , Newdate^)
echo   Dd = DatePart("D"   , Newdate^)

echo Wscript.Echo Mm^&" "^&Dd
)>%fil%

FOR /F "tokens=1-2" %%A in ('cscript //nologo %fil%') do (
        set month=%%A&set day=%%B
	)

del %fil%

:: Create month folder on 1st day of month.

if %day% lss 2 (

   set monthalpha=Jan Feb Mar Apl May Jun Jul Aug Sep Oct Nov Dec

   for /f "tokens=%month%" %%1 in ("!monthalpha!") do (
       set mth=%%1
       
   if not exist !mth! md !mth!
  )
)


Please come back & tell us if your problem is resolved.


Report •

#2
June 1, 2012 at 23:57:21
:: =====  script starts here  ===============
:: 
:: tryjvc.bat  Sat 02-06-2012 13:41:29.09
@echo off & setLocal enableDELAYedeXpansioN

call :sub1
cls
echo today's date: %DD%
goto :eof

:sub1

@echo off > d.d

>> d.d echo E 0100 B4 2A CD 21 B4 4C CD 21
>> d.d echo N DAY.COM
>> d.d echo RCX
>> d.d echo 8
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 F0 B4 4C CD 21
>> d.d echo N MONTH.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 89 C8 B4 4C CD 21
>> d.d echo N YEAR.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 D0 B4 4C CD 21
>> d.d echo N DAT.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo Q

debug < d.d > nul
del d.d

dat
for %%a in (1 2 3 4 5 6 7 8 9                                                                  ) do if errorlevel %%a set DD=0%%a
for %%a in (                  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31) do if errorlevel %%a set DD=%%a
set D=%errorlevel%
echo D %D%
echo Date %DD%

day
if errorlevel 0 set day=Sunday
if errorlevel 1 set day=Monday
if errorlevel 2 set day=Tuesday
if errorlevel 3 set day=Wednesday
if errorlevel 4 set day=Thursday
if errorlevel 5 set day=Friday
if errorlevel 6 set day=Saturday
echo Day %day%

month
for %%a in (1 2 3 4 5 6 7 8 9         ) do if errorlevel %%a set MM=0%%a
for %%a in (                  10 11 12) do if errorlevel %%a set MM=%%a
echo MM %MM%

if %MM%==01 set Mon=Jan
if %MM%==02 set Mon=Feb
if %MM%==03 set Mon=Mar
if %MM%==04 set Mon=Apr
if %MM%==05 set Mon=May
if %MM%==06 set Mon=Jun
if %MM%==07 set Mon=Jul
if %MM%==08 set Mon=Aug
if %MM%==09 set Mon=Sep
if %MM%==10 set Mon=Oct
if %MM%==11 set Mon=Nov
if %MM%==12 set Mon=Dec

echo Mon %Mon%

year
if errorlevel 215 set YYYY=2007
if errorlevel 216 set YYYY=2008
if errorlevel 217 set YYYY=2009
if errorlevel 218 set YYYY=2010
if errorlevel 219 set YYYY=2011
if errorlevel 220 set YYYY=2012
echo Year %YYYY%

set   YYYYMMDD=%YYYY%%MM%%DD%
echo %YYYYMMDD%

del day.com
del month.com
del year.com
del dat.com

goto :eof


::======  script ends here  =================


=====================================
Life is too important to be taken seriously.

M2


Report •
Related Solutions


Ask Question