A Python script to manage video files in a directory that mirrors a media-server folder from Disguise/D3. The script identifies and retains the latest versions of video clips while deleting older versions.
- Supports
.movand.pngfiles - Handles multiple version formats:
- Date-based:
vYYYYMMDD[hhmm][a-z](e.g.,v20240301,v202403011230,v20240301a) - Numeric:
_vN(e.g.,_v1,_v2)
- Date-based:
- Keeps a specified number of most recent versions
- Preserves files without version numbers
- Processes multiple directories in sequence (or the root directory if there are no subfolders)
- Shows detailed file comparison before deletion
- Multiple confirmation steps for safety
python d3_file_cleaner.py <directory> [--versions N]directory: The root directory to scan for files (e.g. "D:\d3 projects\start\objects\vide" The easiest method is to drag this into the command window)--versions N: (Optional) Number of versions to keep. If not provided, you'll be prompted.
- Scans the specified directory and all subdirectories
- For each directory:
- Groups files by base name
- Shows which files will be kept and deleted
- Requires confirmation before deletion
- Shows a final summary of all deletions
- Multiple confirmation steps before deletion
- Shows exactly which files will be kept and deleted
- Requires typing "delete" to proceed
- Final sanity check requiring the exact number of files
- Automatically preserves unversioned files
- Must keep at least 1 version of each file
- Files without version numbers are always preserved
- Script automatically skips directories that don't need changes
- Process stops if deletion is cancelled in any directory
- Shows total space saved across all directories