第二种
FileCopy "原文件名", "新文码山件名"
Kill "原文件名"
方法一:Dim fpPrivate Sub refilename(folderspec)Dim fs, f, f1, fc, sm, hzSet fs = CreateObject("Scripting.FileSystemObject"瞎派)Set f = fs.GetFolder(folderspec)Set fc = f.FilesFor Each f1 In fc
hz = Mid(f1.Name, InStrRev(f1.Name, "."))
Name f1 As fp &"20101007-" &hz
NextMsgBox "修改完成"End SubPrivate Sub Command1_Click()fp = "E:\emot\xhh\"'这里设置文件夹路径,根的需要来修改
If Right(fp, 1) <>"\" And Right(fp, 1) <>"/"
Then fp = fp &"\"Call refilename(fp)
’调用上面的自定义函数,改名End Sub........
方磨前贺法二: '将f:\123\文件下的txt文件改名
Dim files() As String '用于贮存文件名
Dim length As Integer = 0 'files数组长度
Dim fileName As String = Dir$("f:\123\*.txt") '得到第一个.txt文件悔差的文件名
'Dim g As Graphics = Me.CreateGraphics
Do While fileName <>""
'g.DrawString(length, Font, Brushes.Red, length * 10, length * 10)
ReDim Preserve files(length)
files(length) = fileName
length = files.Length
fileName = Dir$() '得到下一个.txt文件的文件名
Loop
For i = 0 To length - 1
Dim oldfileName As String = "f:\123\" + files(i)
Dim newfileName As String = "f:\123\" + "20101007_"+ files(i)
Rename(oldfileName, newfileName) '修改文件名
Next
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)