A collection of scripts for organizing media files.
Scripts are run with uv:
uv run --project ~/code/scripts python ~/code/scripts/<script>.pyScripts operate on the current working directory (and subdirectories recursively where applicable). They refuse to run from ~ as a safety measure.
General-purpose media file renaming. Renames to YYYYMMDD-IDENTIFIERHHMMSS for photos and videos.
Supported extensions: .jpg, .jpeg, .png, .heic, .mp4, .mov, .mkv, .avi
Datetime extraction priority:
- EXIF DateTimeOriginal/DateTimeDigitized/ModifyDate (images only, via Pillow + pillow-heif)
creation_time(orcom.apple.quicktime.creationdate) from ffprobe (videos only, requires ffmpeg installed; uses timezone info from metadata if present, otherwise converts UTC using system timezone rules for the capture date)- Filename -- first valid
YYYYMMDDHHMMSSorYYYYMMDD+HHMMSSsequence - File modification time (
os.path.getmtime)
Identifier: non-numeric portion of the original filename stem.
Duplicate handling: appends -01, -02, etc. before the extension.
Dry run: add --dry-run (or -n) to print the rename plan without changing files. The created-time HHMMSS portion is highlighted in color when it didn't exist in the original name.
Recursively renames files to lowercase and replaces spaces with hyphens. Operates on the current working directory and subdirectories.
Merges video segments from the current directory in natural filename order, so part2.mp4 comes before part10.mp4.
Supported extensions: .mp4, .mov, .mkv, .avi, .m4v
Output: writes merged-YYYYMMDD-HHMMSS<ext> using the first input file's extension. Existing merged-* files are excluded from inputs.
Merge mode: uses ffmpeg concat demuxer with -c copy for a lossless merge. The script checks stream compatibility first with ffprobe and fails clearly if segments have different codecs, stream counts, video dimensions, pixel formats, audio layout, sample rates, or time bases.
Dry run: add --dry-run (or -n) to print the merge order, output filename, and compatibility result without writing output.
Extension filter: add --include .mp4 to only include a specific extension. Repeat the flag to include multiple extensions.
Renames image files (.png, .jpg, .jpeg) in the current directory to sequential numbers, then writes an index.html displaying them in order.
Moves the mouse cursor by one pixel in a random direction every ~5 minutes to prevent the screen from sleeping.
Managed by uv. See pyproject.toml. System dependency: ffmpeg/ffprobe for video metadata.