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

Copy filename.ext to filename-todaysdate.ext

12 views
Skip to first unread message

Calvin Lai

unread,
Mar 2, 2004, 11:42:32 AM3/2/04
to
Is there a way for a batch file to find out, ie, the date (mmddyy or
whatever) of today and then do a COPY FILENAME.EXT
FILENAME-MMDDYY.EXT?

The batch file will be running in command prompt in Windows 2000
server.

Matthias Tacke

unread,
Mar 2, 2004, 1:12:19 PM3/2/04
to
Calvin Lai wrote:

Then news:alt.msdos.batch.nt is the more appropriate group.

This is an faq, with lots of variants posted. Search google
http://groups.google.com/advanced_group_search?group=alt.msdos.batch.nt

Hereis one:

@echo off
if [%1]==[] goto :eof
if not EXIST %1 goto :eof
set mydate=%date:/=%
ren "%~f1" "%~n1-%mydate%.%~x1"

--
Greetings
Matthias

Timo Salmi

unread,
Mar 2, 2004, 1:31:31 PM3/2/04
to
Calvin Lai <Calvi...@shaw.ca> wrote:
> Is there a way for a batch file to find out, ie, the date (mmddyy or
> whatever) of today and then do a COPY FILENAME.EXT
> FILENAME-MMDDYY.EXT?

That is the by far the most frequently asked batch programming
question. It is covered in

243153 Dec 27 2003 ftp://garbo.uwasa.fi/pc/link/tsbat.zip
tsbat.zip Useful MS-DOS batch files and tricks, T.Salmi

Last answered only a couple of days ago. (Well, FAQs _are_
frequently asked, right?)

> The batch file will be running in command prompt in Windows 2000
> server.

In that case you'll want news:alt.msdos.batch.nt and

73123 Feb 2 2004 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Timo's FAQ materials at http://www.uwasa.fi/~ts/http/tsfaq.html

Richard Bonner

unread,
Mar 2, 2004, 4:46:45 PM3/2/04
to
Calvin Lai wrote:
> Is there a way for a batch file to find out, ie, the date (mmddyy or
> whatever) of today and then do a COPY FILENAME.EXT
> FILENAME-MMDDYY.EXT?

*** You need a "rename" batch file, not a "copy" one. Try
"DATEFILE.bat" at:

www.chebucto.ns.ca/ak621/DOS/Bat-Adv2.bat


Richard Bonner
http://www.chebucto.ns.ca/~ak621/DOS/

0 new messages