Such as d: \ wj \ abb123 TXT abc124. TXT batch to abb. TXT ABC. TXT
CodePudding user response:
How to obtain various subdirectories under the file name (including the full path)A post on the VB how to remove the number in the text file name, assume that you have as a function of encapsulation RemoveNumber ()
Dim colFiles As Collection
Dim As Long I
Dim s1 As String
Dim s2 As String
The Set colFiles=SearchFiles (" D: \ wj \ ", "*.txt)
For I=1 To colFiles. Count
S1=colFiles (I)
S2=RemoveNumber (s1)
If s1 & lt;> S2 Then
The Name As s1 s2
End the If
Next
CodePudding user response:
Dizzy, the last time you ask a, now ask again "batch", he would not "turn a curved"!Private Sub Command1_Click ()
Dim strPath As String
Dim strName As String
Dim strTemp As String
Dim As Long I
StrPath="D: \ wj " 'path finally be \
StrTemp=Dir $(strPath & amp; "*.txt)
Do
If (strTemp="") Then Exit the Do
StrName=strTemp
For I=0 To 9
StrName=Replace (strName, I, "")
Next
If (strName & lt;> StrTemp) Then
The Name strPath & amp; StrTemp As strPath & amp; StrName
End the If
StrTemp=Dir $()
Loop
End Sub
CodePudding user response:
If you only care about I can recommend the building function realizes XRename a tool, a command to the problem is solved, concise and efficient and easy to understand,XRename. Exe delete - dir d: \ wj \ string/\ d +/g
XRename introduced: http://blog.csdn.net/sysdzw/article/details/6198257
The problem solving process completely: http://blog.csdn.net/sysdzw/article/details/50499279
XRename related command:
CodePudding user response: