routermax
Goto Top

Letzten Dateizugriff feststellen und in Excel ausgeben

Hallo zusammen,

brauche mal etwas Hilfe bei diesem Script.
Dieses Script habe ich hier im Forum gefunden da, ich nach zuletzt geänderte Dateien suche.
Das Script gibt mir das Ergebinis in einer Textdatei aus. Ich hätte es aber, gerne in einer Excel Datei damit ich besser sortieren kann.
Das sollte Lokal und auf Netzlaufwerken funktionieren.

Sollte ca. so aussehen.
xls

' ChkFileProperties.vbs    

Option Explicit 
On Error Resume Next 

Dim objFSO, objFolder, objSubFld, objLog, f1, f2, colFiles, strMSG, strStart, strLog, i 

strStart = InputBox("Wo solls denn losgehen?","Check4FileProperties")     
strMSG = "Startverzeichnis: " & strStart & vbCrLf & "~~~~~~~~~~~~~~~~~~~~~~~~~~~"     
strLog = "c:\CheckFileProperties.txt"     
Set objFSO = CreateObject("Scripting.FileSystemObject")     
Set objFolder = objFSO.GetFolder(strStart) 

ChkSubFld objFolder 

Private Sub ChkSubFld(StartFolder) 
ChkFiles StartFolder 
Set objSubFld = StartFolder.SubFolders 
For Each f2 in objSubFld 
ChkSubFld f2 
Next 
End Sub 

Private Sub ChkFiles(Start) 
Set colFiles = Start.Files 

For Each f1 in colFiles 
strMSG = strMSG & vbCrLf & objFSO.GetAbsolutePathName(f1) & vbCrLf
strMSG = strMSG & vbTab & "Erstellt: " & f1.DateCreated & vbCrLf    
strMSG = strMSG & vbTab & "Letzter Zugriff: " & f1.DateLastAccessed & vbCrLf    
strMSG = strMSG & vbTab & "Letzte Aenderung: " & f1.DateLastModified & vbCrLf    
strMSG = strMSG & vbTab & "Dateigroeße (bytes): " & f1.Size    
Next 
End Sub 

Set objLog = objFSO.CreateTextFile(strLog, True) 
objLog.WriteLine "Datei wurde erstellt am : " & Now()    
objLog.WriteLine "---------------------------------------"    
objLog.Write strMSG 
objLog.Close 

MsgBox "Fertig!"     
LoadFile strLog 

Private Sub LoadFile(File) 
Dim objShell, strApplication 
strApplication = "notepad.exe"     
Set objShell = CreateObject("WScript.Shell")     
objShell.Run strApplication & " " & File     
set objShell = Nothing 
End Sub

Vielen Dank.

Max

Content-Key: 7812818815

Url: https://administrator.de/contentid/7812818815

Printed on: April 27, 2024 at 11:04 o'clock

Mitglied: 7426148943
Solution 7426148943 Jul 11, 2023 updated at 08:06:41 (UTC)
Goto Top
Powershell Einzeiler in ne CSV:
Get-ChildItem 'D:\Ordner' -File -Recurse | select Fullname,CreationTime,LastWriteTime,LastAccessTime,Length | export-csv .\files.csv -Delimiter ";" -NoTypeInformation -Encoding UTF8  
Fertsch.
Wenn doch VBA sein muss warum auch immer
Sub DateienAuflisten()
    Dim fso As Object, STARTDIR As String, intRow As Long
    Set fso = CreateObject("Scripting.FileSystemObject")  
    STARTDIR = "D:\Ordner"  
    With ActiveSheet
        intRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row  
        With .Cells(intRow - 1, 1).Resize(1, 5)
            .Value = Array("Name", "DateCreated", "DateLastModified", "DateLastAccessed", "Size")  
            .Font.Bold = True
        End With
        
        For Each file In fso.GetFolder(STARTDIR).Files
            .Cells(intRow, "A").Resize(1, 5) = Array(file.Path, file.DateCreated, file.DateLastModified, file.DateLastAccessed, file.Size)  
            intRow = intRow + 1
        Next
    End With
End Sub

Zeppel
Member: Kraemer
Solution Kraemer Jul 11, 2023 at 08:18:57 (UTC)
Goto Top
Zitat von @7426148943:

Powershell Einzeiler in ne CSV:

und wenn es unbedingt Excel sein muss, gibt es das:
https://github.com/dfinke/ImportExcel
Member: routermax
routermax Jul 11, 2023 updated at 08:27:39 (UTC)
Goto Top
Huch, das ging ja schnell. face-smile

Nein, PS ist mir auch lieber. Habe nur beim suchen das VBA gefunden.

Vielen Dank an euch beide.

Max