I need to be able to generate unique names for files. I was considering
that hash alogorithms, but if I had two files with the same name, I'd get
the same hash. I am collecting and storing files and I want to store them
all in the same directory and I want the names to be cryptic and unique.
Any thoughts?
Jerry 13 1550
Jerry Camel wrote: I need to be able to generate unique names for files. I was considering that hash alogorithms, but if I had two files with the same name, I'd get the same hash. I am collecting and storing files and I want to store them all in the same directory and I want the names to be cryptic and unique. Any thoughts?
I needed to do this in the VB3 / 8.3 era for an image capture program.
There was the possibility of many images from many computers on any given
day, so I came up with a base-36 naming system something like this. BTW,
it's been a long time ago so please don't flame for math errors. <g>
Base 36 code:
0 = 0
1 = 1
....
9 = 9
A = 10
B = 11
....
Z = 36
The 8 part of the 8.3 filenames were of this form:
YMDZZXXX
Y -- Year. 0 = 1990, 1=1991, ..., Z = (1990 + 36)
M -- Month. 1 = Jan, 2 = Feb, ... (1-based for ease of reading)
D -- Day 1 = 1, ... (1-based for ease of reading)
ZZ -- "Assigned Computer Number" 36 * 36 possibilities
XXX -- Sequence #. 36 * 36 * 36 possibilities
The program looked in an ini file for the next sequence # for that day,
generated the 8 part of the 8.3 filename, checked the directory, if already
existed incremened & tried again, repeatedly until ZZZ+1 before failing,
saved the full 8.3 (JPG, TIF, WSQ or BMP), updated the ini file.
It worked well. Images captured in the mid 1990's are still part of a
fingerprint biometric test database, I believe.
I think it would satisfy your "cryptic and unique" requirements. <g>
-- Mark
Mark Jerde wrote: BTW, it's been a long time ago so please don't flame for math errors. <g>
Or programmer memory errors either... ;-) I recall now it was a little
more cryptic. I used the first 7 chars to define a "family" of files, all
in the same "enrollment ." The eighth character specified which image and
impression, ie "Face, Right Profile #2" or "Right Index Finger, 3rd
impression." What the eighth character stood for was saved in a ini file
named the first 7 chars .TXT.
The 8 part of the 8.3 filenames were of this form: YMDZZXXX
Almost. Should have been
YMDZZXXA
XX -- Sequence #. 36 * 36 possibilities
A -- "Which Image" designator. 36 possibilites. Saved in
the "family's" .TXT file.
FWIW... <G>
-- Mark
"Jerry Camel" <rl*****@msn.co m> wrote in
news:eM******** *****@tk2msftng p13.phx.gbl: I need to be able to generate unique names for files.
Use GUIDs. They are guaranteed to be unique, and they
are cryptic. Easiest way to generate a GUID is to
ask for one from WinAPI:
--clip--
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Declare Function CoCreateGuid Lib "OLE32.DLL" _
(pGuid As GUID) As Long
Private Function GetGUID() As String
Dim udtGUID As GUID
If (CoCreateGuid(u dtGUID) = 0) Then
GetGUID = _
String(8 - Len(Hex$(udtGUI D.Data1)), "0") & Hex$(udtGUID.Da ta1) & _
String(4 - Len(Hex$(udtGUI D.Data2)), "0") & Hex$(udtGUID.Da ta2) & _
String(4 - Len(Hex$(udtGUI D.Data3)), "0") & Hex$(udtGUID.Da ta3) & _
IIf((udtGUID.Da ta4(0) < &H10), "0", "") & Hex$(udtGUID.Da ta4(0)) & _
IIf((udtGUID.Da ta4(1) < &H10), "0", "") & Hex$(udtGUID.Da ta4(1)) & _
IIf((udtGUID.Da ta4(2) < &H10), "0", "") & Hex$(udtGUID.Da ta4(2)) & _
IIf((udtGUID.Da ta4(3) < &H10), "0", "") & Hex$(udtGUID.Da ta4(3)) & _
IIf((udtGUID.Da ta4(4) < &H10), "0", "") & Hex$(udtGUID.Da ta4(4)) & _
IIf((udtGUID.Da ta4(5) < &H10), "0", "") & Hex$(udtGUID.Da ta4(5)) & _
IIf((udtGUID.Da ta4(6) < &H10), "0", "") & Hex$(udtGUID.Da ta4(6)) & _
IIf((udtGUID.Da ta4(7) < &H10), "0", "") & Hex$(udtGUID.Da ta4(7))
End If
End Function
--clap--
* Petrik Salovaara <pe************ **@poista.solot es.fi.invalid> scripsit: I need to be able to generate unique names for files.
Use GUIDs. They are guaranteed to be unique, and they are cryptic. Easiest way to generate a GUID is to ask for one from WinAPI:
The easiest way to create a GUID in .NET is to use the 'System.Guid'
class...
;-)
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Thank you all for your thoughts... I was going to go with GUIDs, but I just
ended up concat'ing the milliseconds,se conds,minutes,h ours,year,month and
day from Now(). It's pretty much guaranteed to be unique as it will only
run on one system. And what are the chances of two people generating a file
at exactly the same millisecond, anyway? Thanks.
Jerry
"Jerry Camel" <rl*****@msn.co m> wrote in message
news:eM******** *****@tk2msftng p13.phx.gbl... I need to be able to generate unique names for files. I was considering that hash alogorithms, but if I had two files with the same name, I'd get the same hash. I am collecting and storing files and I want to store them all in the same directory and I want the names to be cryptic and unique. Any thoughts?
Jerry
just take ticks property, allready containing all that
every tick is 0.1ms, so you should create 2 files in the same 100nanoseconds
:-)
but to be really sure, add the pc name of the pc guid ;-)
that will be the ultimate unique number ;-)
dominique
"Jerry Camel" <rl*****@msn.co m> wrote in message
news:uy******** ******@TK2MSFTN GP11.phx.gbl... Thank you all for your thoughts... I was going to go with GUIDs, but I
just ended up concat'ing the milliseconds,se conds,minutes,h ours,year,month and day from Now(). It's pretty much guaranteed to be unique as it will only run on one system. And what are the chances of two people generating a
file at exactly the same millisecond, anyway? Thanks.
Jerry
"Jerry Camel" <rl*****@msn.co m> wrote in message news:eM******** *****@tk2msftng p13.phx.gbl... I need to be able to generate unique names for files. I was considering that hash alogorithms, but if I had two files with the same name, I'd
get the same hash. I am collecting and storing files and I want to store
them all in the same directory and I want the names to be cryptic and unique. Any thoughts?
Jerry
Custom algorithms and GUIDs are cool, but I prefer to use system provided
functionality when it provides exactly what you need.
Check out the System.IO.Path' s GetTempFileName method.
I've used the Win32 API equivalent before with flawless results.
--
Andrew J. Marshall
MCP (Visual Basic)
Fairfax, VA
"Jerry Camel" <rl*****@msn.co m> wrote in message
news:eM******** *****@tk2msftng p13.phx.gbl... I need to be able to generate unique names for files. I was considering that hash alogorithms, but if I had two files with the same name, I'd get the same hash. I am collecting and storing files and I want to store them all in the same directory and I want the names to be cryptic and unique. Any thoughts?
Jerry
* "Andrew J. Marshall" <An************ *@ObjectVision. netANTISPAMDEVI CE> scripsit: Custom algorithms and GUIDs are cool, but I prefer to use system provided functionality when it provides exactly what you need.
Check out the System.IO.Path' s GetTempFileName method.
That's what I was looking for when doing some "research" in the
documentation. Nevertheless, these filenames won't be really "unique"
(only unique on the machine).
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
yes but :-)
I also checked that to give the guy an answer
i think that solution is not good enough because you cannot set the
destination directory
i used that also a lot in java, there you can specify your
directory/prefix/suffix of the file
much better
but besides of that i completely agree with you
and also this java-dotnet difference is again one of the strange "why didn't
they copy that feature"
i always see a lot of things copied from java, and then very nice java
features which are not available...
dominique
"Andrew J. Marshall" <An************ *@ObjectVision. netANTISPAMDEVI CE> wrote
in message news:um******** ******@TK2MSFTN GP12.phx.gbl... Custom algorithms and GUIDs are cool, but I prefer to use system provided functionality when it provides exactly what you need.
Check out the System.IO.Path' s GetTempFileName method.
I've used the Win32 API equivalent before with flawless results.
-- Andrew J. Marshall MCP (Visual Basic) Fairfax, VA
"Jerry Camel" <rl*****@msn.co m> wrote in message news:eM******** *****@tk2msftng p13.phx.gbl... I need to be able to generate unique names for files. I was considering that hash alogorithms, but if I had two files with the same name, I'd
get the same hash. I am collecting and storing files and I want to store
them all in the same directory and I want the names to be cryptic and unique. Any thoughts?
Jerry
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave Theese |
last post by:
Hello all,
We're presented with the problem of needing to generate a unique file name.
I've had some thoughts, but also wanted to solicit suggestions from the
group.
Any suggestions for schemes, using only *standard* C++, to do this?
Thanks,
Dave
|
by: Agoston Bejo |
last post by:
I want to enforce such a constraint on a column that would ensure that the
values be all unique, but this wouldn't apply to NULL values. (I.e. there
may be more than one NULL value in the column.)
How can I achieve this?
I suppose I would get the most-hated "table/view is changing,
trigger/function may not see it" error if I tried to write a trigger that
checks the uniqueness of non-null values upon insert/update.
|
by: BuddhaBuddy |
last post by:
Platform is DB2/NT 7.2.9
The table was created like this:
CREATE TABLE MYTEST (
MYTESTOID bigint not null primary key,
FK_OTHEROID bigint not null references other,
FK_ANOTHEROID bigint not null references another,
FK_LASTLYOID bigint not null references lastly,
unique (FK_OTHEROID,FK_ANOTHEROID))
|
by: Jerry LeVan |
last post by:
Hi,
I am futzing around with Andrew Stuarts "Catchmail" program
that stores emails into a postgresql database.
I want to avoid inserting the same email more than once...
(pieces of the email actually get emplaced into several
tables).
Is the "Message-ID" header field a globally unique identifer?
|
by: daldridge |
last post by:
I have a unique-elements/sorting question (who doesn't?), but haven't
yet been able to get appropriate template/select/for-each processing
working. I don't fully grok the Muenchian technique yet (still an XSLT
n00b), but I'm not sure that's the way to go anyway...
What I'm trying to accomplish is generation of XML Schema output from a
given XML input, with "xs:import" elements in the output with the
"namespace" and "schemaLocation"...
| |
by: pstachy |
last post by:
Hi again!
I have another issue. I would like the attribute of the tag <invoice>
to be unique. Made the following schema but unfortunately it doesn't
validate. Could someone please indicate what is wrong or give me other
solution. Thanks Very much.
Regards
------------------------------------------------------------------------------------------------------------------
Schema:
|
by: ba.hons |
last post by:
Hello all,
Was wondering if anyone could provide some info on what could be a
possible solution to a problem am having.
I have to generate a Unique Identifier in C# which I will use to
assign to a user, i dont really need the Unique Identifier's to be
sequential so i was considering using system.time.hour +
system.time.minute. + system.time.second, but am worried about
daylight savings and also people altering the time on the host PC.
|
by: cedric.louyot |
last post by:
Hi,
I've written a schema that looks like :
<xs:schema>
<xs:complexType name="myType">
<xs:sequence>
<xs:element name="e1" type="T1" maxOccurs="unbounded"/>
<xs:element name="e2" type="xs:string"/>
</xs:sequence>
|
by: Alvin SIU |
last post by:
Hi all,
I have a table in Db2 v8 like this:
Team Name Role
------ -------- ---------------------
A Superman Leader
A Batman Member
A WonderWoman Member
B Alvin Leader
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |