Giving computer documents (files) unique names has always been an archiving nightmare. Every institution has thrived to come up with its specific method.
Our institution, for example, decided to use the first five letters of the name of the source institution for incoming documents and the first three letters of the name of the target institution for the outgoing documents, plus the extension. This, for obvious reasons, was not enough, so a yearly serial number (counter) was added at the end of the name. This still caused problems since many documents, over the years, tended to have the same name and the same serial number.
A seemingly perfect coded solution was found at the beginning of the year 2006, the source code is found below. Since two of our correspondents: one in Germany and one in Switzerland found it useful to use a similar naming method, maybe it’s time to make it public and let others profit from it.
The source code is (Visual basic for application, Access XP and Access 2003)
Private Sub DocDump_Exit(Cancel As Integer)
‘case1 there is nothing in docdump field
If Me.DocDump.Text = “” Then Exit Sub
OLDNAME = Trim(Me.DocDump.Text)
ONMYPCNAME = MYDUMP & OLDNAME
PREFIXDATE = Trim(Str(Format(Now, “YYMMDDhhmmss”)))
TEMPNAME = PREFIXDATE & OLDNAME
FINALNAME = MYDUMP & TEMPNAME
‘so we have to change its name
Set BigBoys = CreateObject(“Scripting.FileSystemObject”)
If BigBoys.FileExists(ONMYPCNAME) Then BigBoys.movefile ONMYPCNAME, FINALNAME
If BigBoys.FileExists(FINALNAME) Then Me.DocDump.Text = TEMPNAME
‘Docdump is a text field in a database form
‘MYDUMP is a variable for a directory on your pc where the file is put ang given its final name, example: C:depot
‘the code is activated with the exit event for the text field.
‘you can then add some commands to move the newly renamed file to a master directory on the server, for example.
You certainly have to put some code to make sure that already renamed files do not get renamed again, and other safeguards. But the purpose of this intervention is to show that adding an ever changing 12-character PREFIX (based on year, month, day, hour, minute and seconds will certainly give your document a unique, easily discernable and easily sorted name.
Practical Step-by-step:
Create a new directory (folder), for example: c:depot
Add the variable MYDUMP = “C:DEPOT” to the above code
Put a file named Aco.eml for example in C:depot
Put the characters Aco.eml in the DocDump textbox in yout database.
If the cursor leaves this textbox say on December 12 2007 at 13:20 hours and ten seconds, then the new file name will become 71212132010Aco.eml in C:depot and in the textbox (some companies have opted for full four-character year.)