bat file to create folder with month as name

May 21, 2010 at 22:05:22
Specs: Windows Server 2003
Hi! All
How to create a folder at the start of every month with month and year(like May 2010) as folder name then add export files everyday with datestamp and at the end of the month zip the folder?
Thnx a lot...

See More: bat file to create folder with month as name

Report •

#1
May 22, 2010 at 09:07:34
"add export files everyday"

Not sure what that means.

Are you hoping to schedule this?


=====================================
Helping others achieve escape felicity

M2


Report •

#2
May 24, 2010 at 08:18:26
Export files of database will be added everyday to the folder. And it is to be scheduled to run everyday.
thnx.

Report •

#3
May 25, 2010 at 12:30:50
Hi sid 76,

Maybe this helps, try it out.

@echo off

:MONTH-CHECK-HERE
if %DATE:~-7,2%==01 goto JANUARY
if %DATE:~-7,2%==02 goto FEBRUARY
if %DATE:~-7,2%==03 goto MARCH
if %DATE:~-7,2%==04 goto APRIL
if %DATE:~-7,2%==05 goto MAY
if %DATE:~-7,2%==06 goto JUNE
if %DATE:~-7,2%==07 goto JULY
if %DATE:~-7,2%==08 goto AUGUST
if %DATE:~-7,2%==09 goto SEPTEMBER
if %DATE:~-7,2%==10 goto OCTOBER
if %DATE:~-7,2%==11 goto NOVEMBER
if %DATE:~-7,2%==12 goto DECEMBER

:JANUARY
MD "JANUARY %DATE:~-4,4%"
goto EXIT

:FEBRUARY
MD "FEBRUARY %DATE:~-4,4%"
goto EXIT

:MARCH
MD "MARCH %DATE:~-4,4%"
goto EXIT

:APRIL
MD "APRIL %DATE:~-4,4%"
goto EXIT

:MAY
MD "MAY %DATE:~-4,4%"
goto EXIT

:JUNE
MD "JUNE %DATE:~-4,4%"
goto EXIT

:JULY
MD "JULY %DATE:~-4,4%"
goto EXIT

:AUGUST
MD "AUGUST %DATE:~-4,4%"
goto EXIT

:SEPTEMBER
MD "SEPTEMBER %DATE:~-4,4%"
goto EXIT

:OCTOBER
MD "OCTOBER %DATE:~-4,4%"
goto EXIT

:NOVEMBER
MD "NOVEMBER %DATE:~-4,4%"
goto EXIT

:DECEMBER
MD "DECEMBER %DATE:~-4,4%"
goto EXIT

:EXIT
exit

========== END ==========

Kind Regards,

Muhammed Us\MUs


Report •

Related Solutions

#4
May 29, 2010 at 08:18:22
Hi!
This is only creating the folder for january whereas it should be of current month.
tnx

Report •

#5
May 29, 2010 at 10:12:06
@echo off & if not %OS%!==! setLocal enableDELAYedeXPansion

echo ´*Í^^!ˆð´LÍ^^!à > month.com & 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
del month.com

echo ´*Í^^!‰È´LÍ^^!à > year.com & year
if errorlevel 218 set YYYY=2010
if errorlevel 219 set YYYY=2011
if errorlevel 220 set YYYY=2012
del year.com

echo if not exist %YYYY%%MM% md %YYYY%%MM%
echo move *.* %YYYY%%MM%


=====================================
Helping others achieve escape felicity

M2


Report •

Ask Question