Created
January 3, 2020 00:36
-
-
Save paul-chambers/caab8cc92e7c89f201c38172bf62a3e4 to your computer and use it in GitHub Desktop.
Cleans up cruft that accumulates in some of my media folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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