By: https://github.com/alexpreli
Windows-only script: This project is designed to run on Windows (PowerShell). It is not currently supported on macOS or Linux.
The primary purpose of this script is to search for files across multiple external drives (such as USB drives, CD/DVD, external SSD/HDD, SD cards, and floppy disks) or folders and determine the exact chronological order of specific file types including photos, videos, text documents, and code files.
If you are trying to sort files in chronological order, list your files in chronological order, or use a universal file sorter for multiple drives, this tool is built for that workflow.
Perfect for when: You have accumulated many drives over time and no longer know the exact order of your files, and you don't want to manually figure it out yourself.
💻 System Requirements
- Operating System: Windows 7 or newer (Windows 10/11 are recommended).
- Software: PowerShell 5.1 or newer (included by default in Windows 10/11).
- Permissions: Running as Administrator is strongly recommended to ensure access to all disk locations and optimal performance.
Use these commands to download and run the script using only built-in Windows PowerShell features.
1. Set Execution Policy
Run this command first to allow script execution in your current session:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope ProcessImportant
If you receive an error or a warning prompt, type A and press Enter to "Yes to All" (accept all policies).
2. Download and Run
Then, copy and paste this command to download and start the script:
$url="https://raw.githubusercontent.com/alexpreli/list-files-chronologically/main/LIST_FILES_CHRONOLOGICALLY_v1.PS1"; $dst="$env:TEMP\LIST_FILES_CHRONOLOGICALLY_v1.PS1"; Invoke-WebRequest -Uri $url -OutFile $dst; powershell -NoProfile -ExecutionPolicy Bypass -File $dstYou can find the script file (LIST_FILES_CHRONOLOGICALLY_v1.PS1) here and download it using the "Download raw file" button.
- Without this script: Files sorted by "Date Modified" may show incorrect order (e.g., photos from 2018 appearing after 2020 because they were backed up later).
- With this script: Files are sorted by their actual creation/capture date (EXIF metadata), providing the real chronological timeline.
Its main advantage is accuracy. For media files (like photos and videos), it extracts the true capture date (EXIF) instead of just the 'Date Modified'. For all other files, it uses the 'Last Modified' date.
The final result is a .csv report with all files sorted by their 'real' date, and an optional step to copy all these files into a new, organized folder.
- Accurate Sorting: Uses EXIF "Date Taken" for media (
.jpg,.mp4,.mov,.heic, etc.) and "LastWriteTime" for all other documents. - Flexible Scanning: Choose from pre-defined categories (Photos, Videos, Documents) or enter your own custom file extensions (e.g.,
.log,.bak,.sql). - Multi-Source: Scan multiple drives and folders all at once (e.g.,
D:\,E:\Photos,C:\Users\Public\Documents). - Safe (Read-Only Scan): The script only reads file information. It will not move, modify, or delete any of your original files during the scan.
- CSV Reporting: Generates a simple
.csvreport (compatible with Excel/Google Sheets) listing the file, its date, its original location, and its size. - Optional Copy: After the report is generated, you have the option to copy all the found files into a new, single folder for easy backup or review.
- Performance: The script design is optimized for speed, using efficient native PowerShell commands to traverse directories and extract metadata.
- Easy to Use (.ps1 format): As a single
.ps1file, the script is easy to download and run, with a simple menu-driven interface.
It is highly recommended to run the script with Administrator privileges for it to access all drives, protected folders, and be able to write the final report to any location (like the Desktop).
- Click the Start Menu and type "PowerShell".
- Right-click on "Windows PowerShell".
- Select "Run as administrator".
In the PowerShell window, use the cd (Change Directory) command to navigate to the folder where you saved the script.
# Example if you saved it in your Downloads folder
cd C:\Users\YourName\DownloadsTo run the script, type ./ followed by its name and press Enter.
PowerShell
./LIST_FILES_CHRONOLOGICALLY_v1.PS1Note on Execution Policy: If you get an error message like "running scripts is disabled on this system", you may need to adjust your Execution Policy just for this session. Run this command first, then try running the script again:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope ProcessTip
If prompted for confirmation, type A and press Enter to accept the change.
The script will guide you through the following steps:
Step 1: Select File Category - Choose a pre-defined category (e.g., Media Photo, Documents Text) or select Custom to enter your own extensions.
Step 2: Select File Extension(s) - If you chose a category, you can scan for all extensions in it or pick just one. If you chose 'Custom', you will be prompted to enter your extensions separated by commas (e.g., .log,.bak).
Step 3: Drive Locations - Enter the full paths you want to scan. You can enter a single drive or multiple paths separated by commas.
- Example:
D:\ - Example:
C:\,D:\,E:\ - Example:
C:\Photos,D:\Backup,E:\Documents
Step 4: Output CSV File - Choose the path to save the final chronological report (.csv file). The default location is your Desktop.
Scanning - The script proceeds to scan all specified locations and processes the files. After the scanning process, you will see:
- The start date and end date of the file range
- The exact order of files found in the terminal
- An option to list all files in chronological order in the terminal (showing filename, date, and the drive where each file is located)
Step 5: Copy Sorted Files (Optional) - After the report is generated, you will be asked if you want to copy all the found files to a new destination folder.
Note: If you choose to copy files in Step 5, you can navigate to the created folder in Windows Explorer and click on the "Date modified" column header to sort the copied files from oldest to newest or vice versa.
The final report.csv file will look like this (opened in Excel/Google Sheets):
| RealDate (Accurate) | FileName | FileExtension | OriginalPath | Size (MB) |
|---|---|---|---|---|
| 2018-05-15 10:30:22 | IMG_5012.JPG | .jpg | D:\Photos\Trip_2018\ | 3.2 |
| 2019-12-01 14:05:00 | VacationPlan.docx | .docx | C:\Users\Alex\Docs\ | 0.1 |
| 2021-07-20 09:15:30 | VID_0045.MOV | .mov | E:\Backup\Videos\ | 55.8 |
Important Warning: This script was primarily designed for scanning external drives (such as USB, CD/DVD, external SSD/HDD, SD cards, floppy disks). Scanning internal drives may take significantly longer time and may cause system instability.
However, it can be used on internal drives, including your main system drive (C:). To scan system folders and protected areas effectively, you must run the script as Administrator to avoid "Access Denied" errors. Be aware that scanning a full internal drive can take a significantly longer time and may impact system performance.
The script's purpose is to list and potentially copy files. You are responsible for the data you process.
- The generated .csv report will contain a list of your file names, their full paths, and associated dates.
- The optional "Copy" function will create duplicates of your files.
- Be cautious regarding sensitive data. Do not expose the generated report or the copied files to unauthorized parties if they contain private or sensitive information.
⚙️ How the Script Determines the "Real" Date
The script uses the following logic to determine the sorting date:
Media Files (.jpg, .mp4, .mov, .heic, etc.):
- Priority 1: EXIF Date Taken (camera metadata).
- Priority 2: Creation Time (if EXIF metadata is missing or corrupted).
Other Files (.docx, .pdf, .log, etc.):
- LastWriteTime (the file's last modification date).
Note: To extract EXIF metadata, the script utilizes native PowerShell functionality and does not require third-party modules.
Sort files in chronological order, list my files in chronological order, universal file sorter, file timeline generator, chronological file listing tool, PowerShell file sorter for external drives.
💛 Contributions are welcome!
If you have suggestions or improvements:
- Fork the repository.
- Create a new branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a Pull Request.
If this project saved you time and helped organize your files, consider supporting its development.
Your donation helps maintain and improve this tool.


