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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with file rename

Status
Not open for further replies.

twtickle

IS-IT--Management
Aug 16, 2001
6
US
I need to be able to rename a file in a certian directory without knowing it's full name. The file will be generated and will start with the letter S and end with the extension .txt. I need to be able to have VB rename this file to a standard name before it can be imported into a dabase. Any suggestions?
 
One approach would be to loop thru the directory using the DIR command, then check for formatting.

CheckFile = Dir(<DirectoryName, vbDirectory)
Do While (Len(CheckFile) > 0)
If (Ucase(Left(CheckFile, 1)) = &quot;S&quot;) then
If (Ucase(Right(CheckFile, 4)) = &quot;.TXT&quot;) Then
<Rename CheckFile to Correct Name>
<Process The File>
End If
End If
CheckFile = Dir
Loop

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
can you give me an example using real file and directory names?
 

I need to be able to rename a file in a certian directory without knowing it's full name. The file will be generated and will start with the letter S and end with the extension .txt.

What is the name of this 'certain directory' where the files will be generated?

I need to be able to have VB rename this file to a standard name before it can be imported into a dabase.

What is the 'standard name' that you wish it to be renamed to.

Do you keep the renamed file in the same directory?
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top