PC Review


Reply
Thread Tools Rate Thread

How to create dir with todays date?

 
 
Tim
Guest
Posts: n/a
 
      27th Sep 2004
I have to copy few files daily to a central server from
local W2K server to a remote share on W2K server.
Presently a batch file takes care of this copy. The issue
is I have to pre-create various folders ready on the
destination based on currenmt system date before the
copy, such as:
G:\...\SEP2004\
G:\.....\26SEP\
G:\..\26SEP04\

How to automate this process? (Something like, if not
exist MD G:\....\XXXXX\ based on current system date)

Thanks.
 
Reply With Quote
 
 
 
 
Matthias Tacke
Guest
Posts: n/a
 
      27th Sep 2004
"Tim" wrote:

>I have to copy few files daily to a central server from
>local W2K server to a remote share on W2K server.
>Presently a batch file takes care of this copy. The issue
>is I have to pre-create various folders ready on the
>destination based on currenmt system date before the
>copy, such as:
>G:\...\SEP2004\
>G:\.....\26SEP\
>G:\..\26SEP04\
>
>How to automate this process? (Something like, if not
>exist MD G:\....\XXXXX\ based on current system date)
>

I'd use date time functions from Ritchie Lawrence batch linrary at
http://www.commandline.co.uk


@echo off
setlocal
call :GetDate yy mm dd
call :MonthName %mm% month
echo Year : %yy%
echo Month: %mm% %month%:~0,3% %month%
echo Day : %dd%
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/2000/XP/2003.
::
:: 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
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:MonthName %mm% month
::
:: By: Ritchie Lawrence, 2002-10-04. Version 1.0
::
:: Func: Returns the name of month from the number of the month.
:: For NT4/2000/XP/2003.
::
:: Args: %1 month number convert to name, 1/01 to 12 (by val)
:: %2 var to receive name of month (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS&set /a m=100%1%%100
for /f "tokens=%m%" %%a in ('echo/January February March April May^
June July August September October November December'
) do endlocal&set %2=%%a&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create filename based todays date =?Utf-8?B?TGFycyBIb3N0cnVw?= Microsoft Access VBA Modules 3 11th Jul 2007 04:00 PM
Create a reference to a sheet that changes to todays date =?Utf-8?B?R3Jk?= Microsoft Excel Worksheet Functions 2 14th Aug 2006 05:36 PM
Trying to create an auto field that gives todays date +28 days? =?Utf-8?B?UmFuZ2VyIFRvbnk=?= Microsoft Word Document Management 12 1st Jun 2006 02:23 PM
Create a button that will date stamp todays date in a cell Tom Meacham Microsoft Excel Misc 3 11th Jan 2006 01:08 AM
Date fields automatically updating when field matches todays date!?! Help! Brian Cassin Microsoft Access Forms 1 14th Nov 2003 08:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:44 AM.