A PowerShell module for auditing, organizing, deduplicating, and maintaining large external drives (3 TB+).
| Feature | Description |
|---|---|
| Fast Audit | Recursively scans a drive and exports file metadata to CSV |
| Hash Caching | Stores SHA256 hashes in a JSON cache; only rehashes files that have changed |
| Auto-Categorization | Moves files into Projects / Media / Archives / Uploads / System folders based on extension and keyword patterns |
| Duplicate Resolution | Detects exact duplicates via hash; keeps the newest copy and removes the rest |
| Cleanup | Removes empty directories, reports duplicate groups, compresses the Archives folder |
| Visual Tree Map | Generates a Unicode tree of the drive saved to a .txt file |
| Real-Time Status | Get-DriveStatus returns the currently running operation, start time, and details |
| Scheduled Maintenance | Registers a Windows Scheduled Task to run audits automatically (Daily or Hourly) |
| WPF GUI | Optional graphical launcher for all operations — no command line required |
DriveTools/
├── DriveTools.psd1 # Module manifest
├── DriveTools.psm1 # Module implementation
├── DriveTools.GUI.ps1 # WPF graphical launcher
├── public/ # Public functions (autoloaded)
│ └── Start-DTAuditGui.ps1
├── src/
│ └── UI/
│ └── MainWindow.xaml # WPF window layout
├── lib/ # SQLite database dependencies
│ ├── System.Data.SQLite.dll
│ └── x64/
│ └── SQLite.Interop.dll
├── tests/
│ └── DriveTools.Tests.ps1 # Pester test suite
├── tools/
│ └── Invoke-DriveBenchmark.ps1 # Performance benchmark script
├── profile-snippet.ps1 # PowerShell profile snippet
└── README.md
$dest="$env:USERPROFILE\Documents\PowerShell\Modules\DriveTools"New-Item-Path $dest-ItemType Directory -Force
Copy-Item DriveTools.psd1, DriveTools.psm1, DriveTools.GUI.ps1 -Destination $destCopy-Item public, src, lib -Destination $dest-Recurse -Forcegit clone https://github.com/you/DriveTools.git
Set-Location DriveTools
.\Install.ps1 # copies module to the user module pathImport-Module DriveTools
Get-Module DriveTools |Select-Object Name, Version, ExportedFunctionsImport-Module DriveTools
# 1. Audit the drive$csv=Invoke-DriveAuditFast-RootPath M:\ -IncludeHashes
Write-Host"Report saved to $csv"# 2. Preview categorization without moving anythingInvoke-DriveCategorize-DryRun
# 3. Apply categorizationInvoke-DriveCategorize# 4. Find and remove duplicates (dry-run first!)Resolve-DriveDuplicates-DryRun
Resolve-DriveDuplicates# 5. Clean up empty foldersInvoke-DriveCleanup-RemoveEmptyDirectories -ReportDuplicates
# 6. View a tree map of the driveShow-DriveVisualMap-MaxDepth 3# 7. Schedule nightly maintenanceRegister-DriveMaintenanceTask-Schedule Daily
# 8. Monitor long-running operationsGet-DriveStatusFor users who prefer a visual interface, DriveTools includes a complete WPF Graphical Launcher. It is designed to be highly responsive, running all background drive traversal and hash-computation tasks asynchronously so the UI thread never hangs.
Tip
The GUI is powered by a precompiled C# producer-consumer engine (AuditEngine) utilizing BlockingCollection to decouple disk I/O from computation.
Import-Module DriveTools
Start-DTAuditGui-ScanPath M:\ -CsvLogPath C:\path\to\log.csv- Asynchronous Execution: Traverses the file system and computes SHA256 file hashes in parallel worker threads without blocking the window interface.
- Dynamic Progress Updates: A decoupled progress monitor updates the active folder/file display every 250ms.
- One-Click Operations: Run fast audits, preview auto-categorization, search/remove duplicates, and clean up empty directories without using the command line.
Scans a drive and exports a CSV with file metadata.
-RootPath <string> Drive or folder to scan (default: M:\)
-OutputCsvPath <string> Destination CSV path
-IncludeHashes <switch> Compute SHA256 for every file
Builds or refreshes a JSON hash cache; unchanged files reuse their stored hash.
-RootPath <string> Drive root
-CachePath <string> Path to HashCache.json
Moves files into category folders based on extension and keyword matching.
-RootPath <string> Drive root
-CategoryMap <hashtable> Custom map (category → pattern list)
-DisableDefaultCategoryMap <switch> Skip the built-in category map
-DryRun <switch> Log actions without moving files
Default CategoryMap:
| Category | Triggers |
|---|---|
| Projects | Unity, Project, Source, .sln, .csproj, Perseus |
| Media | .wav, .mp3, .flac, .mp4, .mov, .mkv, .jpg, .png, .psd, .ai … |
| Archives | backup, export, .zip, .rar, .7z, .bak … |
| Uploads | UPLOADS, upload, .torrent, .nfo |
| System | installer, setup, .msi, .exe, .dll, .log |
Hashes all files, groups identical hashes, keeps the newest copy.
-RootPath <string> Drive root
-DryRun <switch> Log what would be deleted without deleting
Composite cleanup: empty directories, duplicate reports, archive compression.
-RemoveEmptyDirectories <switch> Delete zero-item folders
-ReportDuplicates <switch> Log duplicate groups to the log file
-CompressArchives <switch> Zip the Archives\ subfolder
Renders a Unicode tree of the directory structure.
-RootPath <string> Root to map
-MaxDepth <int> Recursion limit (default: 3)
-OutputPath <string> Where to save the .txt file
Registers a Windows Scheduled Task that calls Invoke-DriveAuditFast automatically.
-TaskName <string> Task name (default: DriveMaintenance)
-Schedule <string> Daily | Hourly
Returns the currently active operation, start time, and last-update timestamp.
All operations write to daily log files:
%USERPROFILE%\Documents\DriveToolsLogs\DriveTools_YYYY-MM-DD.log
The SQLite Hash cache database is stored at:
%USERPROFILE%\Documents\DriveToolsLogs\DriveTools_HashCache.db
Requires Pester 5.
Install-Module Pester -Force -SkipPublisherCheck
Invoke-Pester .\tests\DriveTools.Tests.ps1 -Output DetailedYou can override the default drive root and log path in your profile or before importing the module by editing the module variables after import:
Import-Module DriveTools
# Point to a different drive
(Get-Module DriveTools).Invoke({ $Script:Drive_DefaultRoot='E:\' })Or supply -RootPath on every call.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Add Pester tests for any new functions
- Open a pull request
MIT — see LICENSE.