WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

today dir: retrieve, store, use

 
   Home -> Windows Other -> File System RSS
Next:  Non-Authoritative restore on W2K8  
Author Message
Bertoldino

External


Since: Dec 13, 2007
Posts: 21



(Msg. 1) Posted: Tue Feb 19, 2008 2:58 pm
Post subject: today dir: retrieve, store, use
Archived from groups: microsoft>public>win2000>file_system (more info?)

hi
I'd like to use robocopy for some automated backups
my problems:

robocopy seems not to create the destination directory, so I have to create
it before starting copy jobs
I want to create these directories with names like "YYYY_MM_DD_HHMM" (e.g.
2008_02_19_1455)

how can i retrieve these informations, transform them in one variable and
then use it for creation of the directory and next copy job?

my flow: retrieve YYYY, MM, DD, HH, MM; create YYYY_MM_DD_HHMM , store it in
a variable %todaydir%, MD \mypath\%todaydir% ; robocopy source
\mypath\%todaydir%

but... i don't know how to retrieve these values :-/

thanks for your time
Back to top
Login to vote
"Pegasus

External


Since: Dec 22, 2007
Posts: 435



(Msg. 2) Posted: Tue Feb 19, 2008 4:30 pm
Post subject: Re: today dir: retrieve, store, use [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Bertoldino" <finchelabarca.DeleteThis@efelidi.invalid> wrote in message
news:%23KDpM%23vcIHA.4844@TK2MSFTNGP04.phx.gbl...
> hi
> I'd like to use robocopy for some automated backups
> my problems:
>
> robocopy seems not to create the destination directory, so I have to
> create
> it before starting copy jobs
> I want to create these directories with names like "YYYY_MM_DD_HHMM" (e.g.
> 2008_02_19_1455)
>
> how can i retrieve these informations, transform them in one variable and
> then use it for creation of the directory and next copy job?
>
> my flow: retrieve YYYY, MM, DD, HH, MM; create YYYY_MM_DD_HHMM , store it
> in
> a variable %todaydir%, MD \mypath\%todaydir% ; robocopy source
> \mypath\%todaydir%
>
> but... i don't know how to retrieve these values :-/
>
> thanks for your time
>

Your observation is incorrect: robocopy.exe will happily create
the target folder if it does not exist. Try the following batch file:
@echo off
set YYYY=%date:~-4%
set mm=%date:~-7,2%
set dd=%date:~-10,2%
set hh=%time:~0,2%
set min=%time:~3,2%
robocopy d:\temp d:\%YYYY%_%mm%_%dd%_%hh%%mm% *.txt

Depending on your regional settings, you may have to modify the
offsets for mm and dd in order to get the desired mm_dd order.
Back to top
Login to vote
Bertoldino

External


Since: Dec 13, 2007
Posts: 21



(Msg. 3) Posted: Tue Feb 19, 2008 5:23 pm
Post subject: Re: today dir: retrieve, store, use [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Pegasus (MVP) wrote:


> Your observation is incorrect: robocopy.exe will happily create
> the target folder if it does not exist.

oh my!
thanks Pegasus!

> Try the following batch file:
> @echo off
> set YYYY=%date:~-4%
> set mm=%date:~-7,2%
> set dd=%date:~-10,2%
> set hh=%time:~0,2%
> set min=%time:~3,2%
> robocopy d:\temp d:\%YYYY%_%mm%_%dd%_%hh%%mm% *.txt
>
> Depending on your regional settings, you may have to modify the
> offsets for mm and dd in order to get the desired mm_dd order.

many thanks!

and what if i want to use the weekday ?

in italy if i ask for TIME /T the day is like "mar" "mer" "ven" "gio" and so
on.
i suppose in english OS it would be like "wed" "sun" "sat" and so on...

Smile
Back to top
Login to vote
Bertoldino

External


Since: Dec 13, 2007
Posts: 21



(Msg. 4) Posted: Wed Feb 20, 2008 8:23 am
Post subject: Re: today dir: retrieve, store, use [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Bertoldino wrote:


> many thanks!
>
> and what if i want to use the weekday ?
>
> in italy if i ask for TIME /T the day is like "mar" "mer" "ven" "gio"
> and so on.
> i suppose in english OS it would be like "wed" "sun" "sat" and so
> on...
>

sorry, what I said is not correct; first of all, the command is obviously
DATE (not time)
weekday is shown on my workplace OS, but not at home.

and... i can't remember what I did to obtain this information using DATE /T

anyway, I'd like to obtain weekday information and use it as you shown me
with other infomation Smile

(sorry for my "funny" english...)
Back to top
Login to vote
"Pegasus

External


Since: Dec 22, 2007
Posts: 435



(Msg. 5) Posted: Wed Feb 20, 2008 12:01 pm
Post subject: Re: today dir: retrieve, store, use [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Bertoldino" <finchelabarca DeleteThis @efelidi.invalid> wrote in message
news:OqOTnR5cIHA.4936@TK2MSFTNGP03.phx.gbl...
> Bertoldino wrote:
>
>
>> many thanks!
>>
>> and what if i want to use the weekday ?
>>
>> in italy if i ask for TIME /T the day is like "mar" "mer" "ven" "gio"
>> and so on.
>> i suppose in english OS it would be like "wed" "sun" "sat" and so
>> on...
>>
>
> sorry, what I said is not correct; first of all, the command is obviously
> DATE (not time)
> weekday is shown on my workplace OS, but not at home.
>
> and... i can't remember what I did to obtain this information using DATE
> /T
>
> anyway, I'd like to obtain weekday information and use it as you shown me
> with other infomation Smile
>
> (sorry for my "funny" english...)
>
>

There is nothing wrong with your English!

There are several ways to resolve your problem:
a) You could modify the regional settings so that the environmental
variable %date% includes the weekday. This is not a robust
method and it can generate different results for different users.
b) You can modify the registry in the locations below. This is also
not a robust method.
HKEY_USERS\.DEFAULT\Control Panel\International (regional, idate)
HKEY_CURRENT_USER\Control Panel\International
c) You can use one of the many "now.exe" utilities and extract
your information from its output. This works fine but every
machine must have the same flavour of now.exe.
d) You can run a VB Script. This would be the most robust
solution but it gets a bit chatty.
Back to top
Login to vote
Bertoldino

External


Since: Dec 13, 2007
Posts: 21



(Msg. 6) Posted: Wed Feb 20, 2008 1:11 pm
Post subject: Re: today dir: retrieve, store, use [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Pegasus (MVP) wrote:

> There are several ways to resolve your problem:

> b) You can modify the registry in the locations below. This is also
> not a robust method.
> HKEY_USERS\.DEFAULT\Control Panel\International (regional, idate)
> HKEY_CURRENT_USER\Control Panel\International

Hi Pegasus,
why is that method not robust?

does it vary between nt, 2000, xp, vista and servers?

Neutral
Back to top
Login to vote
"Pegasus

External


Since: Dec 22, 2007
Posts: 435



(Msg. 7) Posted: Wed Feb 20, 2008 1:55 pm
Post subject: Re: today dir: retrieve, store, use [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Bertoldino" <finchelabarca.TakeThisOut@efelidi.invalid> wrote in message
news:u8XP9m7cIHA.4936@TK2MSFTNGP03.phx.gbl...
> Pegasus (MVP) wrote:
>
>> There are several ways to resolve your problem:
>
>> b) You can modify the registry in the locations below. This is also
>> not a robust method.
>> HKEY_USERS\.DEFAULT\Control Panel\International (regional, idate)
>> HKEY_CURRENT_USER\Control Panel\International
>
> Hi Pegasus,
> why is that method not robust?
>
> does it vary between nt, 2000, xp, vista and servers?
>
> Neutral

Because it is user-specific and because some applications
appear to change the settings behind your back. I run a very
clean machine, yet I have lost the "Day-of-week" part in the
%date% variable on several occasions. A robust method
works no matter what!
Back to top
Login to vote
Bertoldino

External


Since: Dec 13, 2007
Posts: 21



(Msg. 8) Posted: Wed Feb 20, 2008 3:33 pm
Post subject: Re: today dir: retrieve, store, use [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Pegasus (MVP) wrote:

> Because it is user-specific and because some applications
> appear to change the settings behind your back. I run a very
> clean machine, yet I have lost the "Day-of-week" part in the
> %date% variable on several occasions.

i understand Sad

>A robust method
> works no matter what!

of course I agree with you Smile
i'm trying not to mix "batch" and WSH ... of course because I'm not able
making nothing but "msgbox" with WSH , he he... Wink

Thanks Pegasus. Smile
Back to top
Login to vote
Display posts from previous:   
       Home -> Windows Other -> File System All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
  Windows Other
 Office
 Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support