Dreamweaver
Well-known member
- Local time
- Today, 04:22
- Joined
- Nov 28, 2005
- Messages
- 2,466
Please only post questions to The General Forum Thanks Mick
I've decided to do this while finalising one of my projects file and folder interactions.
Some Background and the way I do things when dealing with large file systems
First I have a main folder that contains about 27 Sub Folders
Like this J:\Entities Folder\A
Because I have a copy of those main folders and all sub-folders on my laptop plus I may decide to move to another drive or server I Store the location in 2 places.
This part is stored in a setup Table "J:\Entities Folder\"
Then when I Add a file I only store This part of the file location A\Incoming Mail\ Hi Mick.txt
To get the full location I put the 2 together like Setup Location & File Location
This is created like This (Which I will leave in place in all functions you'll just need to update the names of tables and fields)
Ext = First Letter Of Entities Name
StrArt = Full File Validated Name of Entity
Select Case Ext
Case "A" To "Z"
'Do Nothing
Case Else
Ext = "0-10"
End Select
StrExtShort = Ext & "\" & StrArt
StrExt = DLookup("FoldersRoot", "tblSetup") & Ext & "\" & StrArt
So The Full Path For A Folder Is Created In StrExt For All New Entities
At the min the system creates a set of default folder As below for each entity added to the system that is Allowed a folder (That depends On the selected Entity Type)
My System is huge hence the need for really good File management being there are over 990,000 Folders and about 470,000 Files not counting Files stored on another drive Called Music which also is linked to Discs And Tracks There's about 75Gb On That drive.
At the min I have 4 Main Linked Databases that hold the main data currently just under 800Mg Plus about 7 import satellites of 1.4Gb, 14Gb Of Other Related Files Like Pictures, Plus the 75Gb Of Music Spread across 3 drives (I was A DJ for 10 Years LOL).
So I have been working towards fully automating what needs to be done with these files and folders within the database All the function I have developed to handle Adding, Editing, Renaming, Moving, Deleting, Backing Up Plus a lot of others will be posted into this topic over the next few weeks I hope somebody finds them useful
First Create The Default Folders For An Entity
I will post an example when I update the system to create default Folders for an entity depending on there selected type as this is quite involved so I'll do an example db for that one.
Editing A File Name
Deleting File
Create A Deleted Items Folder for times when folders cannot be deleted because of included files that you may wish to move to other locations.
This is a custom function I use for my personal system
I've decided to do this while finalising one of my projects file and folder interactions.
Some Background and the way I do things when dealing with large file systems
First I have a main folder that contains about 27 Sub Folders
Like this J:\Entities Folder\A
Because I have a copy of those main folders and all sub-folders on my laptop plus I may decide to move to another drive or server I Store the location in 2 places.
This part is stored in a setup Table "J:\Entities Folder\"
Then when I Add a file I only store This part of the file location A\Incoming Mail\ Hi Mick.txt
To get the full location I put the 2 together like Setup Location & File Location
This is created like This (Which I will leave in place in all functions you'll just need to update the names of tables and fields)
Ext = First Letter Of Entities Name
StrArt = Full File Validated Name of Entity
Select Case Ext
Case "A" To "Z"
'Do Nothing
Case Else
Ext = "0-10"
End Select
StrExtShort = Ext & "\" & StrArt
StrExt = DLookup("FoldersRoot", "tblSetup") & Ext & "\" & StrArt
So The Full Path For A Folder Is Created In StrExt For All New Entities
At the min the system creates a set of default folder As below for each entity added to the system that is Allowed a folder (That depends On the selected Entity Type)
My System is huge hence the need for really good File management being there are over 990,000 Folders and about 470,000 Files not counting Files stored on another drive Called Music which also is linked to Discs And Tracks There's about 75Gb On That drive.
At the min I have 4 Main Linked Databases that hold the main data currently just under 800Mg Plus about 7 import satellites of 1.4Gb, 14Gb Of Other Related Files Like Pictures, Plus the 75Gb Of Music Spread across 3 drives (I was A DJ for 10 Years LOL).
So I have been working towards fully automating what needs to be done with these files and folders within the database All the function I have developed to handle Adding, Editing, Renaming, Moving, Deleting, Backing Up Plus a lot of others will be posted into this topic over the next few weeks I hope somebody finds them useful
First Create The Default Folders For An Entity
I will post an example when I update the system to create default Folders for an entity depending on there selected type as this is quite involved so I'll do an example db for that one.
Code:
Function CreateFolders(Ext As String, StrArt As String) As String
Dim fs
Dim StrExt As String
Dim StrExtShort As String
On Error Resume Next 'GoTo HandleErr
Select Case Ext
Case "A" To "Z"
'Do Nothing
Case Else
Ext = "0-10"
End Select
StrExtShort = Ext & "\" & StrArt
StrExt = DLookup("FoldersRoot", "tblSetup") & Ext & "\" & StrArt
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FolderExists(StrExt) Then
fs.CreateFolder (StrExt)
fs.CreateFolder (StrExt & "\Pictures")
fs.CreateFolder (StrExt & "\Record Covers")
fs.CreateFolder (StrExt & "\Record Covers\Singles")
fs.CreateFolder (StrExt & "\Record Covers\Albums")
fs.CreateFolder (StrExt & "\Pictures\Group Pictures")
fs.CreateFolder (StrExt & "\Book Covers")
fs.CreateFolder (StrExt & "\Record Covers\DVD-Video Covers")
fs.CreateFolder (StrExt & "\Screen Savers")
fs.CreateFolder (StrExt & "\Wallpaper")
fs.CreateFolder (StrExt & "\Media Info")
fs.CreateFolder (StrExt & "\Pictures\animations")
End If
CreateFolders = StrExtShort
End Function
Editing A File Name
Code:
Function EditFileNames(StrFile As String, StrExt As String, StrNewName As String)
Dim fs, F, S
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.fileExists(StrFile) Then
MsgBox "Cannot Find File"
Exit Function
End If
Set F = fs.GetFile(StrFile)
F.Name = StrNewName & StrExt
End Function
Deleting File
Code:
Function DeleteFile(StrFile As String)
Dim fs, F, S
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.fileExists(StrFile) Then
MsgBox "Cannot Find File"
Exit Function
End If
fs.DeleteFile StrFile, True
End Function
Create A Deleted Items Folder for times when folders cannot be deleted because of included files that you may wish to move to other locations.
This is a custom function I use for my personal system
Code:
Function DoMoveToDeletedItems(StrFolder As String)
'First We need to check to see if our folder system has our own deleted items
'This will store only folders with files so the admin can check the files and move them or delete them
'You must also update any stored locations within your db so the links to files are removed
Dim fs
Dim DelFld As String 'Stores the full path to the deleted items folder Sub Folder on Root?
Dim Rt As String
On Error GoTo HandleErr
Rt = DLookup("FoldersRoot", "tblSetup")
DelFld = Rt & "Deleted Items"
'If this folder has not been created IE First time An entity has been deleted with files then create it.
Set fs = CreateObject("Scripting.FileSystemObject")
'Check The Folder Exists
If Not fs.FolderExists(DelFld) Then fs.CreateFolder (DelFld)
'Now we know we have a Deleted Items Move the main Folder and All contents into the deleted Items
fs.MoveFolder Rt & StrFolder, DelFld & "\"
'And Thats That Just Clean Up
HandleExit:
On Error Resume Next
fs = Nothing
Exit Function
HandleErr:
MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
Resume HandleExit
End Function
Last edited: