Find File and Rename 39 Points

I need some code which would search for a file. I would need the code to allow for wildcards like *.txt
I would need the code to allow me to rename the file that wa s found to another name and extention, regardless of its properties ie; read only etc. I only have 39 points left.
Thank You
Who is Participating?
viktornetConnect With a Mentor Commented:
use FindFirstFile() and FindNextFile() for searching for the files needed which also allow wild cards searching... to rename the filename of a file you can use MoveFile().... all of these are Win API calls so you will have to declare them first before using them...

This does all but check attributes.

form with drivebox, dirlistbox, filelistbox, txtbox("txtpattern"), txtbox("txtrename"), button("cmdrename"), button("cmdfind")


Option Explicit
Private Sub Form_Load()
txtPattern.Text = "*.*"
txtRename.Text = ""
cmdrename.Caption = "rename"
cmdFind.Caption = "find"
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
File1.Path = Dir1.Path
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub cmdFind_Click()
File1.Pattern = txtPattern
End Sub

Private Sub cmdrename_Click()
Dim oldname, newname
oldname = Dir1.Path & "\" & File1.FileName
newname = txtRename
Name oldname As newname
End Sub

Private Sub File1_Click()
txtRename.Text = Dir1.Path & "\" & File1.FileName
txtRename.SelLength = Len(txtRename)
End Sub

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.