Archived from groups: microsoft.public.windowsxp.security_admin (
More info?)
Ryan wrote:
> Hello, can anyone give a suggestion?
>
> I need to automate the creation of a file folder that occurs the start of
> each day.
>
> Also the name of the folder needs to be the date of each day e.g. "012405"
>
> Can this be done through XP's utilities or am I going to have to write a
> script?
Hi
With a VBScript (batch solution further down):
'--------------------8<----------------------
' path to parent folder
strBaseFolder = "C:\some\thing"
dateNow = Now
Set objFSO = CreateObject("Scripting.FileSystemObject")
' using ISO 8601 date format yyyymmdd so it is unambiguous
' and easily sortable in Explorer.
strCurrentDate = Year(dateNow) & Right(100 + Month(dateNow), 2) _
& Right(100 + Day(dateNow), 2)
objFSO.CreateFolder strBaseFolder & "\" & strCurrentDate
'--------------------8<----------------------
WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
You can do it with a batch file as well, using e.g the batch date
time functions from Ritchie Lawrence batch library available at
http://www.commandline.co.uk/lib
This works for me:
--------------------8<----------------------
@echo off
setlocal
call :GetDate year month day
set basepath=C:\some folder\path here
:: using ISO 8601 date format yyyymmdd so it is unambiguous
:: and easily sortable in Explorer.
set newfolder=%year%%month%%day%
md "%basepath%\%newfolder%"
endlocal
goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetDate yy mm dd
::
:: By: Ritchie Lawrence, 2002-06-15. Version 1.0
::
:: Func: Loads local system date components into args 1 to 3. For NT4/2K/XP
::
:: Args: %1 var to receive year, 4 digits (by ref)
:: %2 var to receive month, 2 digits, 01 to 12 (by ref)
:: %3 Var to receive day of month, 2 digits, 01 to 31 (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS
set t=2&if "%date%z" LSS "A" set t=1
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do (
for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do (
set %%a=%%d&set %%b=%%e&set %%c=%%f))
endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx