file name creation fiscal yr & Period

May 11, 2009 at 07:21:42
Specs: Windows XP
I need to create a filename for FTP purposes that is in the following format

The 2009-10 would for example be last month. Our fiscal year starts in July.

See More: file name creation fiscal yr & Period

Report •

May 12, 2009 at 02:19:28
This could be done by extracting the year and month from your %date% variable but you didn't supply your date format so here's a script which is date format insensitive:

:: Code begins...
@echo off

set newfile=%temp%\date.vbs
echo otherdate = (Date())>%newfile%
echo   yy = datePart("yyyy", otherdate)>>%newfile%
echo   mm = datePart("m"   , otherdate)>>%newfile%

echo wscript.echo yy^&" "^&mm>>%newfile%

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

del %newfile%

set fismonth=7 8 9 10 11 12 1 2 3 4 5 6

for /f "tokens=%month%" %%1 in ("%fismonth%") do (
    set fiscalmonth=%%1

if %fiscalmonth% lss 10 set fiscalmonth=0%fiscalmonth%


echo %filename%
:: Code ends

Report •
Related Solutions

Ask Question