# Need batch file that will extract day of month



## Alex Ethridge (Apr 10, 2000)

I need a batch file that will extract the day of the month from the computer's date and make an environment variable of that number.

The purpose is to have the batch file then extract that environment variable (numbers 01 or 1 through 31) and make a directory by that name. After a full month of running that batch command every day, there will be 31 folders numbered 01 or 1 through 31.

My knowledge of batch commands isn't very sophisticated so I need help with this.

I've Googled for it, but no success.


----------



## lotuseclat79 (Sep 12, 2003)

Alex Ethridge said:


> I need a batch file that will extract the day of the month from the computer's date and make an environment variable of that number.
> The purpose is to have the batch file then extract that environment variable (numbers 01 or 1 through 31) and make a directory by that name. After a full month of running that batch command every day, there will be 31 folders numbered 01 or 1 through 31.
> My knowledge of batch commands isn't very sophisticated so I need help with this.
> I've Googled for it, but no success.


Alex,

To assure yourself that this works:
Start->Run->Cmd->Ok
cd ../..
set DATE=%date% <- extracts date from system date command
echo %DATE% <- prints out value extracted
set DAY=%DATE:~7,2% <- extracts two characters starting at 8th (0-7)
echo %DAY% <- prints out value extracted

When the new month turns on Thursday, try it again for hopefully, 
Thu 09/01/2005

Strip out the echo commands in a notepad file and save the file as something like dayofmonth.bat

In order to make a new directory, you will have to add the command to do that using the command to make a new directory. Run help in the Cmd window.

-- Tom


----------

