FileName, Size and TimeStamp
Closed
yelli
-
Apr 15, 2010 at 09:09 AM
rizvisa1
rizvisa1
- Posts
- 4479
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- May 5, 2022
Related:
- FileName, Size and TimeStamp
- How to add timestamp to filename in batch file - Forum - Programming
- State information about number and size of partition created - Articles
- Maximum transmission unit size - Guide
- Firefox cache size - Guide
- How to crop multiple images to the same size in powerpoint - Guide
2 replies
rizvisa1
Apr 15, 2010 at 11:23 AM
- Posts
- 4479
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- May 5, 2022
Apr 15, 2010 at 11:23 AM
It would be far easier to do so in VB script.
rizvisa1
Apr 15, 2010 at 03:15 PM
- Posts
- 4479
- Registration date
- Thursday January 28, 2010
- Status
- Contributor
- Last seen
- May 5, 2022
Apr 15, 2010 at 03:15 PM
Insert this in a module of excel and execute TestListFilesInFolder. But before that change the value
sStartAtDir = "C:\Users\haadi\Desktop\"
sStartAtDir = "C:\Users\haadi\Desktop\"
Sub TestListFilesInFolder() Dim sStartAtDir As String sStartAtDir = "C:\Users\haadi\Desktop\" With Range("1:1") .Font.Bold = True .Font.Size = 12 End With Range("A1").Formula = "File Path:" Range("B1").Formula = "File Name:" Range("C1").Formula = "File Size:" Range("D1").Formula = "File Type:" Range("E1").Formula = "Date Created:" Range("F1").Formula = "Date Last Accessed:" Range("G1").Formula = "Date Last Modified:" Range("H1").Formula = "Attributes:" Range("I1").Formula = "Short File Path:" Range("J1").Formula = "Short File Name:" ListFilesInFolder sStartAtDir, True End Sub Sub ListFilesInFolder(SourceFolderName As String, Optional IncludeSubfolders As Boolean = False) Dim FSO As Object Dim SourceFolder As Object Dim SubFolder As Object Dim FileItem As Object Dim lRowBeanCounter As Long lRowBeanCounter = 2 Set FSO = CreateObject("Scripting.FileSystemObject") Set SourceFolder = FSO.GetFolder(SourceFolderName) For Each FileItem In SourceFolder.Files Cells(lRowBeanCounter, 1).Formula = FileItem.Path Cells(lRowBeanCounter, 2).Formula = FileItem.Name Cells(lRowBeanCounter, 3).Formula = FileItem.Size Cells(lRowBeanCounter, 4).Formula = FileItem.Type Cells(lRowBeanCounter, 5).Formula = FileItem.DateCreated Cells(lRowBeanCounter, 6).Formula = FileItem.DateLastAccessed Cells(lRowBeanCounter, 7).Formula = FileItem.DateLastModified Cells(lRowBeanCounter, 8).Formula = FileItem.Attributes Cells(lRowBeanCounter, 9).Formula = FileItem.ShortPath Cells(lRowBeanCounter, 10).Formula = FileItem.ShortName lRowBeanCounter = lRowBeanCounter + 1 ' next row number Next FileItem If IncludeSubfolders Then For Each SubFolder In SourceFolder.SubFolders ListFilesInFolder SubFolder.Path, True Next SubFolder End If Columns("A:J").AutoFit Set FileItem = Nothing Set SourceFolder = Nothing Set FSO = Nothing End Sub
Apr 15, 2010 at 01:02 PM
how will you do such in VB Script?
thanks,
Yelli