|
- Sub t()
- Dim fso, fo, fs, mypath$, f, dic, fon, bl As Boolean
- mypath = "E:\VBA\证件原始图片" '这个路径要修改成自己存放文件的路径
- Set fso = CreateObject("scripting.FileSystemObject")
- Set fs = fso.getfolder(mypath).Files
-
- For Each f In fs
- fon = Split(f.Name, "-")(0) '目录名
- bl = fso.folderExists(mypath & "" & fon)
- If bl Then
- Shell "cmd.exe /c Copy " & f & " " & mypath & "" & fon
- Else
- Set fo = fso.createfolder(mypath & "" & fon)
- Shell "cmd.exe /c Copy " & f & " " & mypath & "" & fon
- End If
- Next f
- Set fo = Nothing
- Set fs = Nothing
- Set fso = Nothing
- End Sub
复制代码 |
|