Using VB6
In a folder, am having n number of text files, file names are like abc.mis-.txt, [email protected], so i want to rename the filenames like abcmis.txt, deffin.txt. I used a function for renaming.
Code
Dim filename3 As String
filename3 = Dir$(txtSourceDatabaseFile & "\*.txt", vbDirectory)
Do While filename3 <> ""
'Function for renaming
Dim strInput As String
Dim stroutput As String
Dim strChar As String
Dim intChar As Integer
Dim intLoop As Integer
strInput = filename3
For intLoop = 1 To Len(strInput)
strChar = Mid$(strInput, intLoop, 1)
intChar = Asc(strChar)
If ((intChar >= 48) And (intChar <= 57)) Or _
((intChar >= 65) And (intChar <= 90)) Or _
((intChar >= 97) And (intChar <= 122)) Or _
(intChar = 95) Then
stroutput = stroutput & strChar
End If
Next
Name txtSourceDatabaseFile & "\" & filename3 As txtSourceDatabaseFile & "\" & stroutput & ".txt"
filename3 = Dir$
Loop
Above Coding is working, the problem is am using while conditon, so it will rename all the txt files, It is giving a names likes
For Example.
The first time giving a fileaname as abc in "stroutput"
The second time giving a filename as abcdef in "Stroutput"
...,
It is adding a previous filename also, because am getting a filename in while loop itself.
How to modify my code.