Skip to content

Instantly share code, notes, and snippets.

@paul-chambers
Created January 3, 2020 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paul-chambers/caab8cc92e7c89f201c38172bf62a3e4 to your computer and use it in GitHub Desktop.
Save paul-chambers/caab8cc92e7c89f201c38172bf62a3e4 to your computer and use it in GitHub Desktop.
Cleans up cruft that accumulates in some of my media folders
#!/bin/bash
set -x
dir="${1:-./}"
if [ ! -z "${dir}" ]
then
find "${dir}" -regex '.*[\.-_][Ss]ample[\.-_].*' -delete
find "${dir}" -regex '.*proof.*\.jpg' -delete
find "${dir}" -regex '.*\/screen[0-9]+\.png' -delete
find "${dir}" -regex '.*\.\(exe\|idx\|nfo\|lnk\|nzb\|sfv\|srr\|srs\|srt\|sub\|sup\|txt\|url\)' -delete
find "${dir}" -depth -mindepth 2 -type d -empty -delete
chgrp -R media "${dir}"
chmod -R ug=rwX,o=rX "${dir}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment