Here are a couple of methods to export the list of files in a directory into a CSV for analysis.
1. Powershell (Wrapped for use in CMD.exe)
The following command is a wrapped Powershell script that will run from a cmd.exe window.
powershell -Command "Get-ChildItem -Path . -File | Select-Object Name,@{Name='SizeBytes';Expression={$_.Length}},@{Name='LastModified';Expression={$_.LastWriteTime}} | Export-Csv -Path '.\file_list.csv' -NoTypeInformation"
Output:
- Name: File name
- SizeBytes: File size in bytes
- LastModified: Timestamp of the last modification
2. Native CMD.exe Prompt
The following is a native command line that can be run from the cmd.exe prompt.
(for /R %f in (*) do @echo %~pf%~nxf) > file_list.csv
Or to export recursively through subfolders as well:
(for /R %f in (*) do @echo "%~nxf",%~zf,"%~tf") > file_list.csv
Explanation:
%~nxf— filename with extension%~zf— file size in bytes%~tf— last modified date/timefor /R— recursively processes all files in subdirectories- Output is saved to
file_list.csvin the current directory