|
楼主 |
发表于 2024-3-22 20:38
|
显示全部楼层
- Function TraverseFile(oFolder As Folder)
- Dim oFile As File
- Dim DateStr, Str
- Dim oDate As Date
- For Each oFile In oFolder.Files
- If InStr(oFile.Name, "IMG") > 0 Then
- DateStr = oFile.Name
- Str = Mid(DateStr, 5, 4) & " / " & Mid(DateStr, 9, 2) & " / " & Mid(DateStr, 11, 2)
- Str = Str & " " & Mid(DateStr, 14, 2) & ":" & Mid(DateStr, 16, 2) & ":" & Mid(DateStr, 18, 2)
- oDate = Str
- 'Debug.Print oDate,
- 'Debug.Print apiSetFileTime(oFile.Path, oDate, oDate, oDate)
- Debug.Print apiSetFileTime(oFile.Path, Str, Str, Str)
- ElseIf InStr(UCase(oFile.Name), "SCR") > 0 Then
- DateStr = oFile.Name
- Str = Mid(DateStr, 5, 4) & " / " & Mid(DateStr, 9, 2) & " / " & Mid(DateStr, 11, 2)
- Str = Str & " " & Mid(DateStr, 14, 2) & ":" & Mid(DateStr, 16, 2) & ":" & Mid(DateStr, 18, 2)
- oDate = Str
- 'Debug.Print oDate,
- Debug.Print apiSetFileTime(oFile.Path, Str, Str, Str)
- Stop
- Debug.Print apiSetFileTime(oFile.Path, oDate, oDate, oDate)
- End If
- Debug.Print oFile.Name, oFile.DateLastModified
-
- Next oFile
- End Function
- Function TraverseFolder(oFolders As Folders)
- Dim oFolder As Folder
- Dim ii
- 'For ii = 1 To oFolders.Cot
- For Each oFolder In oFolders
- 'Set oFolder = oFolders.Item(ii)
- 'Debug.Print oFolder.Path ', oFolder.SubFolders.Count
- If InStr(oFolder.Path, "System Volume Information") <= 0 Then
- 'Debug.Print oFolder.Path, oFolder.SubFolders.Count
- TraverseFile oFolder
- End If
- Next oFolder
- 'Next ii
- End Function
- Sub TraverseFolderFile()
- Dim Fso As FileSystemObject
- Set Fso = New FileSystemObject
- Dim oFolder As Folder, oFile As File
- Dim oFolders As Folders
- Set oFolder = Fso.GetFolder(ThisWorkbook.Path & "")
-
- Set oFolders = oFolder.SubFolders
-
- Debug.Print oFolder.Name
- TraverseFolder oFolders
-
- End Sub
复制代码
|
|