Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of wildcard in path name 2

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US
I have the following code:

sqlstr = "Select Associate_ID, [Associate_First_Name] & ' ' & [Associate_Last_Name] AS OthAssocNo
FROM NewAssociates"

Set rst1 = db.OpenRecordset(sqlstr, dbOpenDynaset, dbSeeChanges)

rst1.MoveFirst
Do While Not rst1.EOF
oldname = "c:\Photos\" & rst1("OthAssocNo") & ".jpg"
newname = "c:\Photos\" & rst1("Associate_ID") & ".jpg"
If Dir(oldname) <> "" Then
Name oldname As newname
'FileCopy
End If
rst1.MoveNext
Loop

This picks up the old FirstName & ' ' & LastName , which matches the name of their picture, looks for the picture and replaces the number with the new associate ID.

I now have to make it work with pictures that have the naming convention of FirstName & ' ' & LastName & <some random characters> & .jpg


Is there some way to use a wildcard in the oldname line so that I can get the entire name using the first and last names?
 
tmpname = "c:\Photos\" & rst1("OthAssocNo") & "*.jpg"
...
oldname = Dir(tmpname)
If oldname <> "" Then
Name oldname As newname
...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
So I don't need to use LIKE with this wild card?

I've looked at the pix files in detail view sorted by name and there don't seem to be any that have duplicate "front ends", so I assume that we don't have a problem catching the correct one.
 
there don't seem to be any that have duplicate "front ends"

The phrase "famous last words" comes to mind.

No great problem if you're doing this as an employee but if this is a system that you're being paid to develop then you could get burned when the inevitable duplicate turns up.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top