|
楼主 |
发表于 2018-8-7 09:01
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub mysearch()
- Dim Fso As New FileSystemObject
- Dim str As String
- Dim Filepath As String
- Dim filename As String
- Dim fs, i, arr(1 To 10000)
- Set fs = Application.FileSearch '设置一个搜索对象
- Dim SearchPath As String
- Dim FileFormat As String
- Dim t As Single
- t = Timer
- Dim Findi As Integer
- Dim objShell, objFolder, objFolderItem, MyFile$, brr(100000, 1000), n&
- Set objShell = CreateObject("shell.application")
-
- FileFormat = Application.InputBox("请输入即将被操作的文件格式")
- SearchPath = Application.InputBox("请输入目标路径,以\结尾", "提示")
-
-
-
-
-
- With fs
- .LookIn = SearchPath '设置搜索路径
- .filename = "*." & FileFormat '要搜索文件名和类型
- .SearchSubFolders = True '是否需要搜索子文件 夹
-
- If .Execute > 0 Then '如果找到文件
- MsgBox "There were " & .FoundFiles.Count & " file(s) found." '显示找到多少个文件
-
-
- For i = 1 To .FoundFiles.Count
-
-
-
-
- filename = Fso.GetFileName(.FoundFiles(i)) '获得文件名
- Filepath = Fso.GetParentFolderName(.FoundFiles(i))
- objFolder = Filepath '-
- Range("B" & i) = filename
- Range("A" & i) = Filepath & "" & filename
-
- '---------------------------------------------------------------------------
- MyFile = Dir(objFolder & "\*.mp4")
- Set objFolder = objShell.Namespace(objFolder)
- 'Set objFolderItem = objFolder.ParseName(MyFile)
-
- Do While MyFile <> ""
- Set objFolderItem = objFolder.ParseName(MyFile)
- If n = 0 Then
- For k = 0 To UBound(brr, 2)
- brr(0, k) = objFolder.GetDetailsOf(0, k)
- n = 1
- brr(n, 0) = MyFile
- brr(n, k) = objFolder.GetDetailsOf(objFolderItem, k)
- Next
- Else
- For k = 0 To UBound(brr, 2)
- brr(n, 0) = MyFile
- brr(n, k) = objFolder.GetDetailsOf(objFolderItem, k)
- Next
- End If
- n = n + 1
- MyFile = Dir
- Loop
- Cells(1, 1).Resize(n + 1, UBound(brr, 2) + 1) = brr
-
- '--------------------------------------------------------------------------------------
- Next i
- Else
- MsgBox "There were no files found."
- End If
- End With
- MsgBox "ojbk" & "耗时" & Format(Timer - t, "0.00") & 秒
- End Sub
复制代码
老师,我尝试着从网上找了点遍历文件的代码和使用shell获取视频详情的代码然后尝试着拼在一起,但是始终不对,会报错.而且导表的时间很长很长,这个能帮忙改一下么,非常感谢 |
|