@UNIQUE[path[,prefix]] : Creates a zero-length file with a unique name in the specified directory, and returns its full name and path. If no path is specified, the file will be created in the current directory. The file name will be FAT-compatible regardless of the type of drive on which the file is created. This function allows you to create a  temporary file without overwriting an existing file.

 

The path must be in quotes if it contains white space or special characters.

 

If path is quoted, the returned filename will also be quoted (if necessary).

 

If prefix is specified, @UNIQUE will use the first three characters as the first three characters of the unique filename.

 

Because the file is created, if the Protect Redirected Output File configuration option is set, you must use the style >! redirection to avoid errors.

 

Rapid, repeated, consecutive invocations of @UNIQUE may occasionally return a non-unique file name (the same name twice, for example), due to a long-standing timing bug in Windows. If you experience this problem you may need to use DELAY, DELAY /M, or BEEP (with a frequency less than 20 Hz) to provide a short delay between invocations. You may also be able to work around the problem by performing some disk I/O activity between invocations, as this can force physical creation of the file on the disk before @UNIQUE is invoked again.

 

Examples:

 

echo %@unique[d:\takecommand28]

D:\takecommand28\UNIE810.tmp

 

echo %@unique[d:\takecommand28,tc]

D:\takecommand28\tc725F.tmp