How to Copy Excel File Names, Paths, and Modified Dates to a Worksheet
Question details
The user wants to generate an Excel list containing workbook file names, folder paths, and last modified dates by scanning a specific directory and its subfolders.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Organizing, tracking, or auditing multiple Excel files stored across various directories and needing to extract their metadata into a single worksheet.
- Observed behavior
- The user needs a functional method to automatically pull file metadata (path, name, and modified date) into Excel columns without manually typing the information.
Ensure you have the exact file path of the target folder ready. If you plan to use the VBA macro method, make sure the Developer tab is enabled in your ribbon and macros are allowed.
Use a VBA Macro with FileSystemObject
Automate the extraction of file names, paths, and modification dates across subfolders directly into your worksheet.
This method utilizes a folder picker dialog to let you select the target directory dynamically. It then uses the FileSystemObject to scan recursively and output the data neatly into columns A, B, and C.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.
Click on 'Insert' in the top menu, then select 'Module' to create a blank script window.
Write or paste a VBA script that utilizes 'Scripting.FileSystemObject' to loop through folders, read file properties, and print 'File.Path', 'File.Name', and 'File.DateLastModified' to the active worksheet cells.
Close the VBA editor and press Alt + F8 to run the macro. Select your desired parent folder when the folder picker dialog appears.

Use Command Prompt and Text to Columns
A quick, code-free method using the Windows Command Prompt to generate a text list of files, which is then parsed in Excel.
List and Manage File Metadata Easily in WPS Spreadsheet
WPS Spreadsheet fully supports advanced data manipulation and VBA macros, allowing you to run scripts to extract file names, paths, and dates smoothly.
- 1. Open WPS Spreadsheet: Launch WPS Office and open a new blank spreadsheet where you want the file list to appear.
- 2. Access the Developer Tab: Navigate to the Developer tab on the ribbon and click on 'VBA Editor' to open the scripting environment.
- 3. Insert the Macro Code: Insert a new module and paste your FileSystemObject macro code designed to list the files.
- 4. Run the Script: Execute the macro and select your target folder. WPS Spreadsheet will populate columns A, B, and C with the extracted file data.

Frequently Asked Questions
How do I enable the Developer tab to run VBA macros?
To enable the Developer tab, go to File > Options > Customize Ribbon. Check the box next to 'Developer' in the right-hand pane and click OK. The tab will now be visible on your ribbon.
Can I modify the VBA script to only list PDF files instead of Excel files?
Yes. If your VBA script specifies a file extension (such as *.xlsx), you can simply change that condition within the code to *.pdf, and the macro will compile a list of PDF files instead.
Does the CMD method easily extract the last modified date?
The standard 'dir' command outputs the modified date alongside the file name. However, since it is exported as raw text, you must carefully use Excel's 'Text to Columns' feature to split the date, time, and file path into clean, individual columns.




