"Torgeir Bakken (MVP)" <Torgeir.Bakken-(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Cliff Cotterill wrote:
>
> > How do you create a unique filename in a batch file?
> > Can the TIME /t and DATE /t be concatenated to a filename variable?
> Hi
>
> One way is to from your batch file create a temporary vbscript
> file on the fly and pick up the result, more here:
>
>
http://groups.google.co.uk/groups?se...TNGP09.phx.gbl
>
> and
> http://www.jsiinc.com/SUBR/tip8600/rh8600.htm
>
>
> You can do it with "pure" 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
A filename derived from the time and date is only guaranteed to be unique
if:
- the clock is never turned back, and if:
- such files are NEVER created outside of the script that uses the feature.
I would tend to add a random field (a la %random%), and check for existence
before assuming otherwise. If the file already existed, the script would
just re-build the name and try again.
/Al