Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Last active March 7, 2026 22:37
Show Gist options
  • Select an option

  • Save thingsiplay/6310b22ea2c7ed74b13fd9f8bfb3dd64 to your computer and use it in GitHub Desktop.

Select an option

Save thingsiplay/6310b22ea2c7ed74b13fd9f8bfb3dd64 to your computer and use it in GitHub Desktop.
Count ROMs
#!/usr/bin/env bash
# Count ROMs
# Simple script to list ROM files by stripping parts of filename starting with
# one of the following characters '_', '(' or '['. Then count remaining
# duplicates and list them with a counter for each name. This is intended to
# count my Romhacks played on emulators, but may work well for any collection.
#
# First argument can be a directory. Defaults to current directory. Files are
# NOT searched recursively.
#
# Usage: count-roms dir
listing="$(find "${1:-.}" -maxdepth 1 -type f -printf '%f\n' |
sed -E \
-e 's/_.*//' \
-e 's/ \(.*//' \
-e 's/ \[.*//')"
printf '%s' "${listing}" | sort | uniq -c
printf '%s' "${listing}" | sort -u | wc -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment