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

Universally Unique Temporary File and Folder names

19 views
Skip to first unread message

Frank P. Westlake

unread,
Nov 14, 2009, 3:58:46 PM11/14/09
to
'FSUtil ObjectID' provides a simple method of obtaining a file name which is very likely to be unique. It is certain that an identical UUID will not be created using the procedures for creating UUIDs, but any UUID can be inadvertantly duplicated by other means. As they say, "give a monkey a typewriter and sufficient time..." it can duplicate something, but I forgot what.

There is no fear of wasting UUIDs created by your machine. As RFC 4122 states "the UUID generation algorithm ... supports very high allocation rates of up to 10 million per second per machine...." So you can safely make 10 million filenames per second if you need to.

The UUID string is 32 characters of hexadecimal gibberish:

4C6D0985E2B811DD86A1806E6f6E6963

Following is a simple method of creating this string:

:: BEGIN SCRIPT :::::::::::::::::::::::::
SetLocal ENABLEEXTENSIONS
FSutil ObjectID delete %~f0
For /F "tokens=2 delims=:" %%2 in (
'FSutil ObjectID create %~f0^|Find "Object ID"'
) Do (
For %%a in (%%2) Do Set "UID=%%a"
)
:: The variable "UID" now contains a unique ID which
:: can be used as a file name or directory name.
FSutil ObjectID delete %~f0
Goto :EOF
:: END SCRIPT :::::::::::::::::::::::::::

The script assigns an object ID to itself and uses that. Before doing so it deletes an object ID if one exists. 'FSUtil ObjectID CREATE' does not overwrite existing object IDs so if the file has one you will always get that same string. After the ID has been saved in the variable "UID" the object ID is removed from the file.

Frank

mokomoji

unread,
Nov 14, 2009, 6:12:01 PM11/14/09
to
i'am monkey ...
where are use?
my temporary internet files\content.ie5\ dir /a
no hex code...
1 2 3 4 5 6 7 8 9 A B C D E F <--- HEX CODE...
MY FOLDER..NAME..


2009-11-14 오후 11:06 <DIR> .
2009-11-14 오후 11:06 <DIR> ..
2009-11-15 오전 08:04 <DIR> 0HIRGT6N
2009-11-15 오전 08:06 <DIR> 0JPFQIVT
2009-11-15 오전 08:03 <DIR> 274RCVC5
2009-11-15 오전 08:00 <DIR> 41MB09QR
2009-11-15 오전 08:02 <DIR> 62ZP2DOD
2009-11-15 오전 08:05 <DIR> 7ESBVHKX
2009-11-15 오전 08:03 <DIR> 89QBSP2F
2009-11-15 오전 08:04 <DIR> 8H63ODAN
2009-11-15 오전 08:03 <DIR> C16BYVSP
2009-11-15 오전 08:00 <DIR> CHEFOPEJ
2009-11-15 오전 08:03 <DIR> CT6JGTMB
2009-11-15 오전 08:05 <DIR> CXE7GHA3
2009-11-14 오후 09:50 67 desktop.ini
2009-11-15 오전 08:05 <DIR> GHQVCH2B
2009-11-15 오전 08:00 <DIR> GXQFW9QN
2009-11-15 오전 08:03 <DIR> I1254XUH
2009-11-15 오전 07:50 9,617,408 index.dat
2009-11-15 오전 08:06 <DIR> JFF9GGQ6
2009-11-15 오전 08:02 <DIR> LRZNL98E
2009-11-15 오전 08:00 <DIR> O9UFSXYZ
2009-11-15 오전 08:04 <DIR> OL6341EZ
2009-11-15 오전 08:06 <DIR> PHOL9E8O
2009-11-15 오전 08:06 <DIR> Q7MX3U0U
2009-11-15 오전 08:05 <DIR> QXT6NYXC
2009-11-15 오전 08:00 <DIR> S1CD4XSZ
2009-11-15 오전 07:50 <DIR> W5UVCXIF
2개 파일 9,617,475 바이트
26개 디렉터리 16,073,629,696 바이트 남음
NO HEX CODE..~!!!

Temporary File and Folder names <-- where are standerd...?
i don't know..ㅠ_ㅠ yes i'am monkey..
i not understand

Frank P. Westlake

unread,
Nov 14, 2009, 6:55:34 PM11/14/09
to
"mokomoji"
news:6b7bcf67-dc95-48c9...@h40g2000prf.googlegroups.com...

> where are use?

Some people want to be certain that they use unique names when making
temporary files. The discussion is sometimes here. Many different
methods have been suggested for creating unique names. I offered the
UUID method as one more method to choose from.

> 2009-11-15 ���� 08:04 <DIR> 0HIRGT6N
>
> NO HEX CODE..~!!!

I think maybe "0HIRGT6N" is a random number which has been converted to
Base64. It is only my guess.

Frank


mokomoji

unread,
Nov 14, 2009, 8:09:47 PM11/14/09
to
how use?
i'am use

Usage : fsutil objectid delete <filename>

Eg : fsutil objectid delete C:\Temp\sample.txt

Usage : fsutil objectid delete <filename>

Eg : fsutil objectid delete C:\Temp\sample.txt

i wan't practical use example view..

Frank P. Westlake

unread,
Nov 15, 2009, 1:27:18 AM11/15/09
to
"mokomoji" 4dba-93b8-8...@b25g2000prb.googlegroups.com...
> how use?

> i wan't practical use example view..


A simple example. Find files, make a list, print files using list:

:: BEGIN SCRIPT :::::::::::::::::::::::::::::::::
@Echo OFF
SetLocal ENABLEEXTENSIONS

REM Get a file name:

Call :MkTempFileName TempFile
Echo.Temporary file is "%TEMP%\%TempFile%".

REM Make a directory path:
Set "#News=%LOCALAPPDATA%\Microsoft\Windows Mail"
Set "#News=%#News%\news.albasani.net\alt.msdos.batch.nt"

PushD "%#News%"


REM Make a search string:
Set "#Str=From: .Frank P. Westlake"


REM Make a file list:
FindStr/RMB /C:"%#Str%" *.nws > "%TEMP%\%TempFile%"

REM Print files in list:
For /F %%1 in ('TYPE "%TEMP%\%TempFile%"') Do echo.Print %%1

PopD

REM Remove temporary file:
ERASE "%TEMP%\%TempFile%"

REM Goto :EOF
Goto :EOF

:MkTempFileName filename
Set "File=%~f0"
FSutil ObjectID delete "%File%"


For /F "tokens=2 delims=:" %%2 in (

'FSutil ObjectID create "%File%"^|Find "Object ID"'
) Do (
For %%a in (%%2) Do Set "%~1=%%a"
)
FSutil ObjectID delete "%File%"
Goto :EOF

:: END SCRIPT :::::::::::::::::::::::::::::::::::

Frank


Todd Vargo

unread,
Nov 15, 2009, 1:47:40 AM11/15/09
to

For creating temporary file/folder names, KISS.

@echo off
:loop
set UID=%random%
if exist %uid% goto :loop


If you insist on wanting more characters...

@echo off
:loop
set UID=%random%%random%%random%%random%%random%%random%%random%%random%
set UID=%uid:~0,32%
if exist %uid% goto :loop

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

Frank P. Westlake

unread,
Nov 15, 2009, 2:31:22 AM11/15/09
to
"Todd Vargo" news:hdo860$14sj$1...@adenine.netfront.net...

> For creating temporary file/folder names, KISS.

> If you insist on wanting more characters...

Sure, you could use random numbers if you want. That technique has been
around for a long time. I prefer to use the time variable because the
random variable can sometimes produce the same value.

My subject line indicates that my routine is for temporary files but if
you read the message you'll see that I'm addressing the problem of
unique file names; I don't even use the word "temporary". If you want
unique file names then A UUID is much more reliable than %random%, which
can sometimes be repeated if used at the same time.

Frank

Todd Vargo

unread,
Nov 15, 2009, 3:04:55 AM11/15/09
to

"Frank P. Westlake" <frank.w...@yahoo.com> wrote in message
news:hdoaod$3bv$1...@news.albasani.net...

Apparently you just want to argue because we don't agree.

Frank P. Westlake

unread,
Nov 15, 2009, 3:44:44 AM11/15/09
to
"Todd Vargo" news:hdocrp$1ei0$1...@adenine.netfront.net...

> Apparently you just want to argue because we don't agree.


No, I am trying to make accurate statements which you seem to continue
to misunderstand.

Regarding random variables, try the following script (named CMDTEST.CMD
here) with this command line:

CMDTEST | CMDTEST something

:: CMDTEST.CMD ::::::::::::::::::::::::::::::::::::::::::::::
@Echo OFF
SetLocal ENABLEEXTENSIONS DISABLEDELAYEDEXPANSION
:: DISABLEDELAYEDEXPANSION so I can use exclamation mark.
Set "NOTunique=%Random%"
If "%1"=="" (
Echo.Hi! I am %NOTunique%.
) Else (
MORE
Echo.NO! I am %NOTunique%.
)

mokomoji

unread,
Nov 15, 2009, 4:00:38 AM11/15/09
to
sir. Todd Vargo source.. . i thank.. similar

i source...think..
:loof
set var=%date%%time%%random%%random%%random%%random%%random% <--very
slow very sorry...T_T
if exist %var% (
goto :loof
) else (
echo md %var:~0,32%
echo. >%var:~0,32%.tmp
)

and..
sir. frank source.. i don't know.. *_*
thank you simple example.
very very sorry i'am monkey brain.. T_T)a
i don't know...
to error message.

output
Temporary file is "C:\DOCUME~1\MyHome\LOCALS~1\Temp
\3c5bf3ec8dd0de118d3d001a4d4422e4".
the system cannot find the path specified.
FINDSTR: Cannot open *.nws
Press any key to continue . .

mouse drag save source code..
:: BEGIN SCRIPT :::::::::::::::::::::::::::::::::
@Echo OFF
chcp 437


SetLocal ENABLEEXTENSIONS
REM Get a file name:
Call :MkTempFileName TempFile
Echo.Temporary file is "%TEMP%\%TempFile%".
REM Make a directory path:
Set "#News=%LOCALAPPDATA%\Microsoft\Windows Mail"
Set "#News=%#News%\news.albasani.net\alt.msdos.batch.nt"
PushD "%#News%"
REM Make a search string:
Set "#Str=From: .Frank P. Westlake"
REM Make a file list:
FindStr/RMB /C:"%#Str%" *.nws > "%TEMP%\%TempFile%"
REM Print files in list:
For /F %%1 in ('TYPE "%TEMP%\%TempFile%"') Do echo.Print %%1
PopD
REM Remove temporary file:
ERASE "%TEMP%\%TempFile%"
REM Goto :EOF

pause


Goto :EOF
:MkTempFileName filename
Set "File=%~f0"
FSutil ObjectID delete "%File%"

For /F "tokens=2 delims=:" %%2 in (

'FSutil ObjectID create "%File%"^|Find "Object ID"'
) Do (


For %%a in (%%2) Do Set "%~1=%%a"
)
FSutil ObjectID delete "%File%"
Goto :EOF
:: END SCRIPT :::::::::::::::::::::::::::::::::::


http://groups.google.com/group/alt.msdos.batch.nt/browse_thread/thread/1c0ecc80e016fea7#
frank..u see.......~!!

full source
:
:

environment maker
where point..
:
:
:
output

i'am sorry
i brain..true monkey..
i try.. human.. brain... ago..

Frank P. Westlake

unread,
Nov 15, 2009, 4:22:21 AM11/15/09
to
"mokomoji"
news:fc1470d5-c186-4d6e...@b36g2000prf.googlegroups.com...

> to error message.

I thought you would change the script to work on your cmputer.

The purpose of "Call :MkTempFileName TempFile" is to get this file name:


> Temporary file is "C:\DOCUME~1\MyHome\LOCALS~1\Temp
> \3c5bf3ec8dd0de118d3d001a4d4422e4".


That is the only purpose. It is only a name. It is a name which should
never be accidently duplicated on any computer if the same method is
used.

Frank


Todd Vargo

unread,
Nov 15, 2009, 9:00:47 AM11/15/09
to

What knowledge am I supposed to gain from this? You are trying to teach me
something but you have not made an intelligent statement here. <shrug>

Timo Salmi

unread,
Nov 15, 2009, 9:58:58 AM11/15/09
to
Frank P. Westlake <frank.w...@yahoo.com> wrote:
> The purpose of "Call :MkTempFileName TempFile" is to get this file name:
>> Temporary file is "C:\DOCUME~1\MyHome\LOCALS~1\Temp
>> \3c5bf3ec8dd0de118d3d001a4d4422e4".

> That is the only purpose. It is only a name. It is a name which should
> never be accidently duplicated on any computer if the same method is
> used.

The current discussion and some of the parrying has baffled me, but
anyway: A trivial answer, not giving an absolute certainly. The
chance of an overlap, however, is astronomically small with this
temporary file name where also the individual lowercase environment
variables (FAQ) are easily found out, as we know

%COMPUTERNAME%%year%%month%%day%%hour%%minute%%second%%millisecond%%RANDOM%

But maybe I have missed the essence of the thread.

All the best, Timo

--
Prof. Timo Salmi mailto:t...@uwasa.fi ftp & http://garbo.uwasa.fi/
Hpage: http://www.uwasa.fi/laskentatoimi/english/personnel/salmitimo/
Department of Accounting and Finance, University of Vaasa, Finland
Useful CMD script tricks http://www.netikka.net/tsneti/info/tscmd.htm

Frank P. Westlake

unread,
Nov 15, 2009, 10:22:55 AM11/15/09
to
"Timo Salmi" news:4b001731$0$26349$9b53...@news.fv.fi...

> ... A trivial answer, not giving an absolute certainly. The


> chance of an overlap, however, is astronomically small with this
> temporary file name where also the individual lowercase environment
> variables (FAQ) are easily found out, as we know
>
> %COMPUTERNAME%%year%%month%%day%%hour%%minute%%second%%millisecond%%RANDOM%

Easily found out? Extracting individual components of date and time are
not easy and the extraction needs to be tailored for each user's
environment. So for your extra work you get multiple extraction
routines, one for each user, andthe slight increase in collisions.

However, for a script designed for a single user machine that is a good
solution, but the computername would not be necessary.

Frank


Timo Salmi

unread,
Nov 15, 2009, 1:19:14 PM11/15/09
to
Frank P. Westlake wrote:
> "Timo Salmi" news:4b001731$0$26349$9b53...@news.fv.fi...

>> variables (FAQ) are easily found out, as we know
>> %COMPUTERNAME%%year%%month%%day%%hour%%minute%%second%%millisecond%%RANDOM%
>
> Easily found out? Extracting individual components of date and time are
> not easy and the extraction needs to be tailored for each user's
> environment. So for your extra work you get multiple extraction

Yes Frank, easily found out. The word (FAQ) was in my message for a good
reason. A task that has been discussed and solved in a generic,
locale-independent way many times over.

Todd Vargo

unread,
Nov 15, 2009, 12:27:15 PM11/15/09
to
mokomoji wrote:
> sir. Todd Vargo source.. . i thank.. similar
>
> i source...think..
> :loof
> set var=%date%%time%%random%%random%%random%%random%%random% <--very
> slow very sorry...T_T
> if exist %var% (
> goto :loof
> ) else (
> echo md %var:~0,32%
> echo. >%var:~0,32%.tmp
> )

Your code variation has some major flaws. First, %date% and %time% directly
returns invalid filename characters on many systems. My system returns this.

E:\>echo %date%%time%
Sun 11/15/200912:12:50.93

Second, you test for existence of %var% which may contain over 32 characters
but then use the modified %var:~0,32% to create a folder and then use
%var:~0,32%.tmp to create a file in the same folder. These are three
completely different values. There is no consistency.

What puzzles me is why you say very slow. Slower then what? By what standard
is slow being compared against?

Frank P. Westlake

unread,
Nov 15, 2009, 1:55:47 PM11/15/09
to
"Timo Salmi" news:4b004621$0$3841$9b53...@news.fv.fi...

> Frank P. Westlake wrote:
>> "Timo Salmi" news:4b001731$0$26349$9b53...@news.fv.fi...
>>> variables (FAQ) are easily found out, as we know
>>> %COMPUTERNAME%%year%%month%%day%%hour%%minute%%second%
>>> %millisecond%%RANDOM%
>>
>> Easily found out? Extracting individual components of date and
>> time are not easy and the extraction needs to be tailored for
>> each user's environment. So for your extra work you get multiple
>> extraction
>
> Yes Frank, easily found out.

Your FAQ 178 shows about 40 lines of a hybred script. Your FAQ 1 on
extracting date also refers to a hyprid script for locale independant
extraction of dates and times. That is not "easily found out."

This is easy:

FSutil ObjectID delete %~f0
For /F "tokens=3 delims=: " %%a in (
'FSutil ObjectID create %~f0^|Find "Object ID"'
) Do Set "TmpFile=%%a"

Frank


Frank P. Westlake

unread,
Nov 15, 2009, 2:21:04 PM11/15/09
to
"Frank P. Westlake" news:hdpj0d$jqe$1...@news.albasani.net...

> ... hybred script.
> ... hyprid script ...

Next time I'll try "hydrud" and "hyqrod".

For the language translators, the word should be "hybrid".

Frank


Timo Salmi

unread,
Nov 15, 2009, 3:22:03 PM11/15/09
to
Frank P. Westlake wrote:

> "Timo Salmi" wrote:
>> Yes Frank, easily found out.
> That is not "easily found out."
> This is easy:

Dear Frank,

Ok. I am not into arguing perceptions and convictions. Whatever solution
works for you and pleases you best.

mss

unread,
Nov 15, 2009, 4:18:01 PM11/15/09
to
On 2009-11-15, Frank P. Westlake <frank.w...@yahoo.com> wrote:

> hybred script...

Chuckle right - wonder how well that translates?

--
later on,
Mike

Frank P. Westlake

unread,
Nov 15, 2009, 5:00:34 PM11/15/09
to
"mss" news:hdpr69$14a$1...@news.albasani.net...
> Frank P. Westlake
>> hybred script...

> Chuckle right - wonder how well that translates?

I didn't know I knew Texan too.

Frank
--
http://en.wikipedia.org/wiki/Languages_of_Texas


mss

unread,
Nov 15, 2009, 5:36:40 PM11/15/09
to
On 2009-11-15, Frank P. Westlake <frank.w...@yahoo.com> wrote:

> I didn't know I knew Texan too.

=) well at least I can read your posts now
as your word wrap issue seems to be solved.

Re; unique temp file/folder.
What's wrong with something as simple as:

@echo off
> foo.vbs echo Set objFSO = CreateObject("Scripting.FileSystemObject")
>> foo.vbs echo Set WSHShell = CreateObject("Wscript.Shell")
>> foo.vbs echo WScript.echo objFSO.GetTempName
cscript //nologo foo.vbs
del foo.vbs

--
later on,
Mike

Frank P. Westlake

unread,
Nov 15, 2009, 6:10:24 PM11/15/09
to
"mss" news:hdpvpn$8ka$1...@news.albasani.net...

> ... your word wrap issue seems to be solved.

Thanks, I was hoping for verification.


> Re; unique temp file/folder.
> What's wrong with something as simple as:
>
> @echo off
>> foo.vbs echo Set objFSO = CreateObject("Scripting.FileSystemObject")
>>> foo.vbs echo Set WSHShell = CreateObject("Wscript.Shell")
>>> foo.vbs echo WScript.echo objFSO.GetTempName
> cscript //nologo foo.vbs
> del foo.vbs

It does the job. I simply create a directory in %TEMP% with the name of
my script and the time appended to it and then throw files in there with
real names that mean something to me:

Set "MN=%~n0"
Set "TIME="
Set "inst=%time::=%"
Set "inst=%inst:.=%"
Set "inst=%inst: =%"
Set "MY=%temp%\%MN%.%inst%"

Almost every option is good for most jobs, but someone always comes in
here after the best solution has been made and demonstrates how it won't
fit that person's need.

Temp files created by the OS (your VBS example) I believe are unique
only in the drectory they were cerated in. So if you want to move a temp
file of that type to another directory you might have a problem.

The problem with using %DATE%, %TIME%, and %RANDOM% is that they could
have been set to a non-automatic value in the environment before the
script was run. For example, a preceeding script could have 'SET
"DATE=First of May, Ninteen Hundered and Twenty Seven"'. So when using
those variables they must first be deleted (SET "DATE=") before use.

Random number variables can be duplicated by a script which pipes data
to itself. This happened to me in real life, on a real computer. I wrote
a script which encodes and decodes transformation formats. I had one
script read a file, decode it and pipe the output to another instance to
be encoded in another format. It took me a long time to figure out what
was causing the errors I was getting from a script which worked well
otherwise. The problem was that they both created the same temporary
file.

If you want to avoid all of those problems and more then maybe the best
option is to use universally unique file names. The routine to do so is
short and simple and the UUIDs will not be duplicated anywhere is the
universe at any time; unless you give a monkey a typewriter and a lot of
time.

Frank


Dr J R Stockton

unread,
Nov 15, 2009, 5:38:13 PM11/15/09
to
In alt.msdos.batch.nt message <hdoaod$3bv$1...@news.albasani.net>, Sat, 14
Nov 2009 23:31:22, Frank P. Westlake <frank.w...@yahoo.com> posted:

>"Todd Vargo" news:hdo860$14sj$1...@adenine.netfront.net...
>
>> For creating temporary file/folder names, KISS.
>
>> If you insist on wanting more characters...
>
>Sure, you could use random numbers if you want. That technique has been
>around for a long time. I prefer to use the time variable because the
>random variable can sometimes produce the same value.

Remember, though, that for many people one hour of local time is
repeated each Autumn. Granted, it will be in the small hours : but some
people and systems will be working then. Moral : use GMT whenever
possible.

Those travelling sufficiently far towards the Eastern side of the
International Date Line will also be retarding their local time.

Remember also that if your computer clock runs a little (or more) fast
and you routinely correct it, perhaps from an NNTP server, then at each
correction a small amount of time may be repeated.

If you are able to access the full internal state of a pseudo-random
number generator, then you have access to a value with will only repeat
after a knowable large number of times (after which the whole lot
repeat, ad nauseam).

Good margin, however achieved.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05.
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

Message has been deleted

mokomoji

unread,
Nov 16, 2009, 10:00:26 AM11/16/09
to
i perfection source....
source... normality form
@echo off <--- essentiality insert
i' not full source...

u'r source approval...
u'r source quotation
i source algorithm write...
not perfection i source...

slow puzzles i joke..~!! u'r... my brain?? real? monkey brain????????
realry?

sir frank source question..
my version.. xp korean...
find... problem & trouble

korean version os trouble?
china..
japan..

vernacular language use version os...

cmd message trouble?
english version..
"Object ID"'
korean version..
"개체 ID"

korea version..message
FSutil ObjectID create 111.bat

개체 ID : fc4c7437b7d2de118d3e001a4d4422e4 <--- korea MS JOKE..?
translation
BirthVolume ID : 4ed9c06c97d05a4080a20481b15cb87c <--- NOT
translation
BirthObjectId ID : fc4c7437b7d2de118d3e001a4d4422e4
도메인 ID : 00000000000000000000000000000000


SIR. FRANK------KOREA VERSION..----------------
@echo off
setLocal ENABLEEXTENSIONS
for /l %%l in (1,1,1000) do (
FSutil ObjectID delete 111.bat


For /F "tokens=2 delims=:" %%2 in (

'FSutil ObjectID create 111.bat^|Find "개체 ID"'
) Do (
For %%a in (%%2) Do echo %%a
)
)
FSutil ObjectID delete 111.bat
pause

Frank P. Westlake

unread,
Nov 16, 2009, 10:25:31 AM11/16/09
to
"mokomoji"
news:28ad894b-c48d-47bb...@m33g2000pri.googlegroups.com...

> my version.. xp korean...
> find... problem & trouble

This version gets the first line only. It might work for any language. I
use only the colon ':' as a delimiter (delims=:) so it should not care
about language. The inside FOR removes spaces from the front of the file
name.

:: BEGIN SCRIPT :::::::::::::::::::::::::
Set "File="
FSutil ObjectID delete %~f0


For /F "tokens=2 delims=:" %%2 in (

'FSutil ObjectID create %~f0'
) Do (
If NOT DEFINED File (
For %%a in (%%2) Do Set "File=%%a"
)
)
:: END SCRIPT :::::::::::::::::::::::::::

This version also only gets the first line and uses a GOTO to leave FOR:

:: BEGIN SCRIPT :::::::::::::::::::::::::
FSutil ObjectID delete %~f0


For /F "tokens=2 delims=:" %%2 in (

'FSutil ObjectID create %~f0'
) Do (
For %%a in (%%2) Do Set "File=%%a"
Goto :break
)
:break
:: END SCRIPT :::::::::::::::::::::::::::


Frank


mokomoji

unread,
Nov 16, 2009, 3:27:28 PM11/16/09
to
for 1000 -----------test
@echo off
set time1=%time%
SetLocal EnableDelayedExpansion
set "UID=FSutil ObjectID create 444.bat"
:loop
if !aa! equ 1000 goto :end
set /a aa=%aa%+1
FSutil ObjectID delete 444.bat
For /f "tokens=3* delims= " %%a in ('%UID%') Do (
echo %%b
goto :break
)
:break
goto :loop
:end
endlocal
echo start--%time1% end--%time% >time.txt
pause

start-- 5:15:08.90 end-- 5:15:49.06
2for my 1for optimazer..41sec...only output

@echo off
SetLocal EnableDelayedExpansion
set time1=%time%
IF exist test.txt del test.txt

for /l %%l in (1,1,1000) do (

:roof
SET UID=!RANDOM!!RANDOM!!RANDOM!!RANDOM!!RANDOM!!RANDOM!!RANDOM!!
RANDOM!
set UID=!UID:~0,32!
echo !UID!
if exist !UID!.TXT goto :roof
ECHO !UID!.TXT > !UID!.TXT
)

:end
echo start -- %time1% end -- %time% >RANDOM.txt
pause

start -- 5:16:33.62 end -- 5:16:34.03
output and file make...1sec..~(__~)
sorry sir. frank..


before test..source start koreversion..-- 5:20:54.18 end --
5:21:35.31 ------ 41sec..

@echo off
set time1=%time%
SetLocal ENABLEEXTENSIONS


for /l %%l in (1,1,1000) do (
FSutil ObjectID delete 111.bat

For /F "tokens=2 delims=:" %%2 in (

'FSutil ObjectID create 111.bat^|Find "개체 ID"'
) Do (


For %%a in (%%2) Do echo %%a
)
)
FSutil ObjectID delete 111.bat

echo start -- %time1% end -- %time% >fsutil.txt
pause

sir. frank u'r remake source...and time check..re test..~!!!
set time1=%time%
for 1000.............................
u'r source..
:
:
echo start -- %time1% end -- %time% >filename.txt

Frank P. Westlake

unread,
Nov 16, 2009, 3:45:04 PM11/16/09
to
"mokomoji"
news:fc2fe660-8efc-425b...@h40g2000prf.googlegroups.com...

> frank u'r remake source...and time check..re test..~!!!


If time is more imporatant then universally unique file names then use
the faster routine.

Frank


Frank P. Westlake

unread,
Nov 16, 2009, 6:18:28 PM11/16/09
to
"mokomoji"
news:fc2fe660-8efc-425b...@h40g2000prf.googlegroups.com...
> for 1000 -----------test


If you need 1000 files it might be better to use FOR/L. Something like
this:

Call :GetTempName TempName
For /L %%i in (1,1,1000) Do TYPE NUL: >!TempName!.%%i
:: Now you have: %TempName%.1, %TempName%.2, %TempName%.3, etc.
Goto :EOF

:GetTempName
SetLocal
:: Make a file name using your favorite way and
:: save it to "%~1"
EndLocal & Set "%~1=%TmpFileName%"

Frank

mokomoji

unread,
Nov 16, 2009, 7:27:20 PM11/16/09
to
On 11월17일, 오전8시18분, "Frank P. Westlake" <frank.westl...@yahoo.com>
wrote:

sir frank...
we..are.. no numbering..
random count..

u'r first title write..
"Universally Unique Temporary File and Folder names "
and u say.. who's..temp forder make..
random name.. use..want..

i want algorithm accelerating random code make

and... i know...
32bit.. count some 2,000,000,000 end numbering..
you uid source make.. stand?
high speed unique random code how make...

now source overwrite code...
one play two play 1~1000 numbering overwrtie..
first number new start..
we are want.. not index,not ago , not overlapping , not repetition

i'am brain.. step mokey ...
i'am not fish brain..


Todd Vargo

unread,
Nov 16, 2009, 11:00:10 PM11/16/09
to

"Frank P. Westlake" <frank.w...@yahoo.com> wrote in message
news:hdrqte$uo5$1...@news.albasani.net...

FSutil does not exist on my system.
I can use the following batch though.

:: Caveat: Do not pipe this batch to itself!
@echo off
setlocal enableextensions
call :GetUUID
echo %UUID%
goto :eof
::
:: Caveat emptor:
:: Sequence of %random% digits will repeat for each
:: instance of batch if this batch is piped to itself.
:GetUUID
setlocal enableextensions enabledelayedexpansion
set "random="
set count=0
set chrs=abcdefghijklmnopqrstuvwxyz0123456789
set chrs=%chrs%%chrs%%chrs%
:UUIDLOOP
set /a num=1%random:~-2%-100
set UUID=%UUID%!chrs:~%num%,1!
set /a count+=1
if %count% lss 32 goto :UUIDLOOP
endlocal & set "UUID=%UUID%"
goto :eof

Message has been deleted

I'm_HERE

unread,
Nov 17, 2009, 4:14:48 AM11/17/09
to
good idea Frank

-----------8<--------------------------

@echo off
for /f "tokens=2delims=:" %%a in (
'fsutil objectid delete %~s0 ^&
fsutil objectid create %~s0 ^&
fsutil objectid delete %~s0'
) do Call :Trim %%a & goto:ObjUid

:ObjUid
echo Fichier Temp {%filetmp%}
cd.>%filetmp%
pause
goto:eof

:Trim
set filetmp=%*
goto:EOF

-----------8<--------------------------

Frank P. Westlake

unread,
Nov 17, 2009, 5:02:44 AM11/17/09
to
"Todd Vargo" news:hdt751$30qe$1...@adenine.netfront.net...

> FSutil does not exist on my system.
> I can use the following batch though.

Nice idea. It can be made into a valid RFC 4122 UUID with a few changes.
the characters must be only hexadecimal:

Set "chrs=0123456789ABCDEF"

Adjust num accordingly:

Set /A "num %% = 16"

UUIDs containing random or pseudo-random values are version 4. RFC 4122
states:

*************************************************************
The version 4 UUID is meant for generating UUIDs from
truly-random or pseudo-random numbers.

The algorithm is as follows:

o Set the two most significant bits (bits 6 and 7) of the
clock_seq_hi_and_reserved to zero and one, respectively.

o Set the four most significant bits (bits 12 through 15) of
the time_hi_and_version field to the 4-bit version number
from Section 4.1.3.

o Set all the other bits to randomly (or pseudo-randomly)
chosen values.
*************************************************************

The clock_seq_hi_and_reserved field is byte 8 (offset 16/17). For
version 4 this value is the variant combined with random garbage. The
variant for this type of UUID is value 2 (0b10) set into the two high
bits of this byte. The quote above identifies them in the reverse order;
01 into 6,7 is the same as 10 into 7,6. The remainder of this byte is
random. The value 2 shifted left to those bits becomes 8 in offset 16,
the high nybble of the byte. OR this with your random value for the
other bits:

If %count% EQU 16 Set /A "num=0x8 | (num&0x3)"

The time_hi_and_version field is bytes 6 and 7 (offsets 12/13 and
14/15). This value is the version number, 4 for random UUIDs, combined
with random garbage. The high byte is to the right, byte 7 (offset
14/15). The value 4 (0b0100) is shifted left to the high nybble, which
in the character string is offset 14.

If %count% EQU 14 Set "num=4"

So, unless I lost track of the forest by the trees:

> :: Caveat: Do not pipe this batch to itself!
> @echo off
> setlocal enableextensions
> call :GetUUID
> echo %UUID%
> goto :eof
> ::
> :: Caveat emptor:
> :: Sequence of %random% digits will repeat for each
> :: instance of batch if this batch is piped to itself.
> :GetUUID
> setlocal enableextensions enabledelayedexpansion
> set "random="
> set count=0

REM set chrs=abcdefghijklmnopqrstuvwxyz0123456789
REM set chrs=%chrs%%chrs%%chrs%
set chrs=0123456789ABCDEF

> :UUIDLOOP
> set /a num=1%random:~-2%-100

Set /A "num %% = 16"
If %count% EQU 14 Set "num=4"
If %count% EQU 16 Set /A "num=0x8 | (num&0x3)"

> set UUID=%UUID%!chrs:~%num%,1!
> set /a count+=1
> if %count% lss 32 goto :UUIDLOOP
> endlocal & set "UUID=%UUID%"
> goto :eof

Frank


Frank P. Westlake

unread,
Nov 17, 2009, 5:05:46 AM11/17/09
to
"I'm_HERE"
news:4ccffbcf-064d-44c7...@u7g2000yqm.googlegroups.com...
> nice idea FRANK !
>
> -----------8<------------------------

>
> @echo off
> for /f "tokens=2delims=:" %%a in (
> 'fsutil objectid delete %~sf0 ^&
> fsutil objectid create %~sf0 ^&
> fsutil objectid delete %~sf0'

> ) do Call :Trim %%a & goto:ObjUid


Yes, that looks better!

Frank


foxidrive

unread,
Nov 17, 2009, 6:00:24 AM11/17/09
to
On Tue, 17 Nov 2009 01:08:43 -0800 (PST), "I'm_HERE" <wali...@gmail.com>
wrote:

>nice idea FRANK !
>
>-----------8<------------------------
>
>@echo off
>for /f "tokens=2delims=:" %%a in (
> 'fsutil objectid delete %~sf0 ^&
> fsutil objectid create %~sf0 ^&
> fsutil objectid delete %~sf0'
>) do Call :Trim %%a & goto:ObjUid
>

>:ObjUid
>echo Fichier Temp {%filetmp%}
>cd.>%filetmp%
>pause
>goto:eof
>
>:Trim
>set filetmp=%*
>goto:EOF
>

>----------8<--------------------------

Hmmm... It doesn't work on FAT volumes.

===[paste]===
"The FSUTIL utility requires a local NTFS volume.
===[paste]===


Frank P. Westlake

unread,
Nov 17, 2009, 6:10:13 AM11/17/09
to
"foxidrive" news:df05g5pn0iqu733fk...@4ax.com...

> Hmmm... It doesn't work on FAT volumes.


No, I thought I wrote somewhere that object IDs on Windows required
NTFS. My apology if I neglected it.

Frank


Todd Vargo

unread,
Nov 17, 2009, 5:54:14 PM11/17/09
to

"Frank P. Westlake" <frank.w...@yahoo.com> wrote in message
news:hdtslg$d5$1...@news.albasani.net...

> "Todd Vargo" news:hdt751$30qe$1...@adenine.netfront.net...
>
> > FSutil does not exist on my system.
> > I can use the following batch though.
>
> Nice idea. It can be made into a valid RFC 4122 UUID with a few changes.
> the characters must be only hexadecimal:
snip...

Interesting. For the sake of holding to RFC 4122 UUID, the number of
possible unique values are reduced and 3 additional calculations/conditions
are evaluated per character generated. I'll have to flip a coin to decide
which method I like best.

Frank P. Westlake

unread,
Nov 17, 2009, 6:42:57 PM11/17/09
to
"Todd Vargo" news:hdv9ia$gnq$1...@adenine.netfront.net...

> For the sake of holding to RFC 4122 UUID, the number of
> possible unique values are reduced and 3 additional
> calculations/conditions are evaluated per character
> generated. I'll have to flip a coin to decide which
> method I like best.

Then you don't need a UUID. A UUID is a UUID (RFC 4122 compliant) so
that other applications can recognize that it is a UUID. It has those
codes in there to tell them that, and it's in hex so it won't bother
their alergies. It seems that all you need is a string of random
characters.

I did not suggest RFC 4122 UUIDs as filenames so that applications and
systems would be RFC 4122 compliant; I suggested them because FSUtil
provides a simple means of obtaining a filename which should be unique
if it is necessary to have a truely unique name. It has been shown here
that there are many methods of obtaining pseudo-unique filenames and any
one of them might be good enough. I wasn't trying to eliminate those
methods, I was adding another to them.

The only other advantage of using UUIDs as filenames that I can think of
is not likely to occur, and that would be if ALL files had UUIDs as the
filename. The descriptive string we now use as a filename would be
attached as an alternate data stream and displayed instead of the UUID
filename. This is sort of the reverse of the object ID idea. The Object
ID is optionally attached to the file as an alternate data stream (not a
named stream) and provides a method of absolutely identifying the file.
(I think in the newest OSs the Object ID might be automatically
assigned.)

If all files had UUIDs as the name then there would be a lot fewer
problems. Identification problems would be eliminated, the need to
rename because a file exists by that name would be eliminated,
accidentally overwriting a file with the same name would be eliminated,
and so on. The benefits are probably described on Wikipedia under
"Object ID".

In the console, DIR might show something like this:

2009-11-06 09:50 146 AttsaNiceFile.txt
2009-11-06 08:26 1,234 News.txt
2009-11-06 11:43 4,321 News.txt
2009-11-05 09:23 2,143 News.txt


Multiple files with the same display name. If you commanded your system:

MOVE NEWS.TXT C:\NEWS

the system would spit out an error message listing the UUID names and
descriptive names and ask you which one.

My apology for the rant. It wasn't directed at you, it was just me
acting out an idea. The Object ID idea will probably do much of the
same, but UUID filenames can be retrofitted onto FAT media.

Frank

Frank P. Westlake

unread,
Nov 18, 2009, 4:23:29 AM11/18/09
to
"Frank P. Westlake" news:hdtslg$d5$1...@news.albasani.net...
> "Todd Vargo" news:hdt751$30qe$1...@adenine.netfront.net...

> Nice idea. It can be made into a valid RFC 4122 UUID with
> a few changes.

But perhaps not with the changes I indicated. It seems that my byte 6
and 7 are reversed, but I'm not certain of that yet. Microsoft's byte
order is not what I expected and it doesn't appear to be an -endian
problem. I doubt many are interested in a UUID version 4 script but in
the interest of accuracy I'll research the problem and submit a
corrected script.

Frank


Frank P. Westlake

unread,
Nov 18, 2009, 5:40:03 AM11/18/09
to
:: Caveat: Do not pipe this batch to itself!
:: By Todd Vargo, 2009-11-17; altered 2009-11-18 FPW

@echo off
setlocal enableextensions
call :GetUUID
echo %UUID%
goto :eof
::
:: Caveat emptor:
:: Sequence of %random% digits will repeat for each
:: instance of batch if this batch is piped to itself.
:GetUUID
setlocal enableextensions enabledelayedexpansion
set "random="
set count=0
set chrs=0123456789ABCDEF
:UUIDLOOP
set /a num=1%random:~-2%-100
Set /A "num %% = 16"
If %count% EQU 12 Set "num=4"
0 new messages