Hi Micron, i should share the full procedure, so a table with folder names, there is an option to save to that folder or generate a new folder (Case 5) in the table field Image Name is called Add New so if a folder doesn't exist you want to save files, you can Mk Dir called new name
then the file name is called the same as folder name, file names will always be:
In DMT Image Folder all files will be called > DMT Image Number
Here is the saving procedure i have:
1: I have this code that transfers all files from Camera SD Card
Code:
varOpt = Me.optCamera
Select Case varOpt
Case Is = False
Me.optOpenImages = False
Me.optRename = False
Me.optResize = False
Me.optSend = False
Me.optStoredImages = False
Exit Sub
Case Else
Me.txtImageID = ""
Me.optOpenImages = True
strPathFrom = Forms!frmMainMenu!cboDrive & "\DCIM\101MSDCF\"
strPathTo = "T:\DMT Ltd\Cam Images\"
strFiles = Dir(strPathFrom & "*.jpg")
While strFiles <> ""
i = i + 1
strName = i & " " & Format(Now(), "dd-mm-yy") & ".jpg"
Name strPathFrom & strFiles As strPathTo & strName
strFiles = Dir
Wend
MsgBox ("Images Saved:" & vbCrLf & vbCrLf & _
"You Can Now Eject The SD Card From Your Computer"), vbInformation + vbOKOnly, "FILES MOVED"
End Select
2: now files are transferred to a local folder,
rename them into either current folder name or optional add new folder
Code:
varOpt = Me.optRename
Select Case varOpt
Case Is = False
Exit Sub
Case Else
Set rs = CurrentDb.OpenRecordset("Select * From tblImageName")
With rs
Do Until rs.EOF
strBody = strBody & Chr(149) & " " & rs.Fields("ID") & " " & Chr(149) & " " & rs.Fields("ImageName") & vbCrLf
rs.MoveNext
Loop
End With
varFileOpt = InputBox("Enter What You Want To Call Your File Names ?" & vbCrLf & vbCrLf & _
strBody, "ENTER NUMBER")
Me.txtImageID = varFileOpt
End Select
Select Case varFileOpt
Case Is = 5
strSaveName = InputBox("Enter Your New File Name That Wasn't Listed ?", "STORE NEW FILE NAME")
Set rs = CurrentDb.OpenRecordset("Select * From tblImageName")
With rs
.AddNew
!ImageName = strSaveName
.Update
.Close
End With
MsgBox ("New Image Name Saved:" & vbCrLf & vbCrLf & _
"Now Select Rename Option Again"), vbInformation + vbOKOnly, "NEW NAME SAVED"
Me.optRename = False
Case Is = 18
Exit Sub
Case Else
sPath = "T:\DMT Ltd\Cam Images\"
sOldFIle = Dir(sPath & "*.jpg")
strFileName = DLookup("ImageName", "tblImageName", "[ID] = " & varFileOpt)
While sOldFIle <> ""
i = i + 1 '= 1 to how many files
Debug.Print i
x = DMax("ID", "tblID") '= current max number
Set rs = CurrentDb.OpenRecordset("Select * From tblID")
With rs
.Edit
!ID = i ' Update the table with the total count of files
.Update
.Close
End With
x = DMax("ID", "tblID") + i ' return the numbers after updating table
sNewFile = strFileName & " " & "Img " & x & ".jpg" ' new files are called 3,4,5,6,7,8,9
'next files should be called 10,11,12 (assuming there is 3 more)
Name sPath & sOldFIle As sPath & sNewFile
sOldFIle = Dir
Wend
End Select
Hope this helps you to help me which once again is greatly appreciated