Incremental Foldername BatchJob

May 16, 2009 at 09:59:04
Specs: Win XP
Howdy all!

I need your urgent help! I am looking for a batchScript who would be placed in scheduled tasks and each week it would create a new folder, ex. "2009_weekXX" (where xx is just an incremental number based on the current week, no real need for a calendarcheck, just the ability to set the "StartWeekNumber". Does anyone feel up tor the task? :D

See More: Incremental Foldername BatchJob

Report •

May 16, 2009 at 13:39:34
The following will generate what you want. It's based on the How-To posting Manipulate Date by Wahine here It's not strictly batch scripting but then manipulating date info in batch scripting is notoriously difficult.

The script is date format insensitive.

:: Code begins...
@echo off

set newfile=%temp%\date.vbs
echo otherdate = (Date())>%newfile%
echo   yy = datePart("yyyy", otherdate)>>%newfile%
echo   wy = datepart("ww"  , otherdate)>>%newfile%
echo wscript.echo yy^&" "^&wy>>%newfile%

FOR /F "tokens=1-2" %%A in ('cscript //nologo %newfile%') do (
        set year=%%A
        set woy=%%B
del %newfile%

if %woy% lss 10 set woy=0%woy%

echo Output = %year%-Week%woy%

:: if not exist %year%-week%woy%\ md %year%-week%woy%\
:: Code ends..

Report •

May 16, 2009 at 23:33:59
thank you for the quick response! i will try this out as right away!

Report •

May 16, 2009 at 23:56:12
i think that i am doing something wrong, what am i missing?
i get the following output

The system cannot find the path specified.
Output = Input-WeekError:

Report •

Related Solutions

May 17, 2009 at 00:49:01
Sorry, that's because the path to your temp folder contains spaces.

Please amend the start of the script to read:

@echo off

if not exist c:\temp\ md c:\temp\
set temp=c:\temp\

set newfile=.....etc...

Report •

Ask Question