|
- Sub PDF文件分类()
- Dim fso As Object, reg As Object, mPath As String
- Set reg = CreateObject("VBScript.RegExp")
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set fls = fso.GetFolder(ThisWorkbook.Path).Files
- With fso
- For Each i In fls
- If .GetExtensionName(i) = "pdf" Then
- reg.Pattern = "\d+$"
- mPath = .BuildPath(ThisWorkbook.Path, reg.Replace(.GetBaseName(i), "")) & ""
- If Not .FolderExists(mPath) Then
- .CreateFolder (mPath)
- End If
- .MoveFile i.Path, mPath
- End If
- Next
- End With
- End Sub
复制代码
正在学习正则表达式和FSO,弄了一上午,当作练习了 :) |
|