Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Date command in a bat file.

247 views
Skip to first unread message
Message has been deleted

foxidrive

unread,
May 26, 2006, 8:12:09 AM5/26/06
to
On 26 May 2006 03:24:27 GMT, my wrote:

> Hi,
>
> In my cpda.bat file
> copy %1 %1.%date:~12,2%%date:~4,2%%date:~7,2%
>
> cpda work.brd
> gives me
> work.brd.060525
>
> How do I modify it for
> cpda work.brd
> to give me
> work.brd.060525-1620
> where 1620 represents 4:20pm

Use similar commands with the %time% variable.

-%time:0,2%%time:3,2%

Todd Vargo

unread,
May 26, 2006, 8:39:34 AM5/26/06
to

"my" <add...@is.invalid> wrote in message
news:447674eb$0$65504$742e...@news.sonic.net...

>
> Hi,
>
> In my cpda.bat file
> copy %1 %1.%date:~12,2%%date:~4,2%%date:~7,2%
>
> cpda work.brd
> gives me
> work.brd.060525
>
> How do I modify it for
> cpda work.brd
> to give me
> work.brd.060525-1620
> where 1620 represents 4:20pm

Did you try parsing %time% already? After try parsing %time% you will notice
there is a space before hours less than 10. To assure hours less than 10 are
formatted with a leading zero, store %time% in a variable then replace space
with zero.

set dt=%date:~12,2%%date:~4,2%%date:~7,2%-%time:~0,2%%time:~3,2%
set dt=%dt: =0%
copy %1 %1.%dt%

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Todd Vargo

unread,
May 26, 2006, 8:57:37 AM5/26/06
to

Todd Vargo

unread,
May 26, 2006, 9:20:43 AM5/26/06
to

Todd Vargo

unread,
May 26, 2006, 9:20:43 AM5/26/06
to

Todd Vargo

unread,
May 26, 2006, 9:20:43 AM5/26/06
to

Todd Vargo

unread,
May 26, 2006, 9:22:34 AM5/26/06
to
Message has been deleted

foxidrive

unread,
May 26, 2006, 10:37:02 AM5/26/06
to
On 26 May 2006 13:50:40 GMT, my wrote:

> Fri, 26 May 2006 13:22:34 GMT Todd Vargo <tlv...@sbcglobal.netz> wrote:
>| set dt=%date:~12,2%%date:~4,2%%date:~7,2%-%time:~0,2%%time:~3,2%
>| set dt=%dt: =0%
>| copy %1 %1.%dt%
>
>

> From my new bat file
> copy %1 %1.%date:~12,2%%date:~4,2%%date:~7,2%-%time:0,2%%time:3,2%

Try the code above, that Todd posted.

Message has been deleted
0 new messages