Maggie:
Below is some sample code for both renaming the files and updating the new
column in your table. As I do not know all of your particulars, this is
just an example. It uses the FileSystemObject to reference the appropriate
folder and iterate through all the files in the folder. You will need to
reference the Microsoft Scripting Runtime to use the FileSystemObject. This
code assumes that you have an entry in your table for each file in the
specified folder. Since I have a reference to the file, I just used the
Name property of the file to rename it, however, Doug's suggestion of using
the VBA Name Statement would also work nicely inside the loop to rename the
file.
Function RenameFiles()
Dim fso As New Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim fil As Scripting.File
Dim sOldFileName As String
Dim sNewFileName As String
Dim sExtension As String
Dim sSQL As String
Dim iPeriod As Integer
Set fld = fso.GetFolder("C:\MyFolder")
For Each fil In fld.Files
sOldFileName = fil.Name
iPeriod = InStrRev(sOldFileName, ".")
sExtension = Right(sOldFileName, Len(sOldFileName) - iPeriod + 1)
sNewFileName = Left(sOldFileName, iPeriod - 1) & "_NEW" & sExtension
'File is renamed here
fil.Name = sNewFileName
If sExtension = ".jpg" Then
sSQL = "UPDATE MyTable SET NewField ='" & sNewFileName & "'
WHERE MyJPGField = '" & _
sOldFileName & "';"
ElseIf sExtension = ".mpg" Then
sSQL = "UPDATE MyTable SET NewField ='" & sNewFileName & "'
WHERE MyMPGField = '" & _
sOldFileName & "';"
Else
'File with extension other than .jpg or .mpg
End If
CurrentDb.Execute sSQL
Next fil
Set fso = Nothing
Set fld = Nothing
Set fil = Nothing
End Function
--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
message Hello all and thank you in advance,
Scenario:
Folder with 1000's of jpgs, and mpgs.
1 Database holds two columns for the names. One for the jpgs, one for the
mpgs.
How do I use access to change the file names?
I have to rename them to a concatenation (hope I spelled that right.

),
of various fields and make a new column with that concatenation and rename
all the files with the new file names. I have over 1,000 jpg's and mpgs to
do
and definitely do not want to them manually.
Were do I start?