Skip to content

Instantly share code, notes, and snippets.

@ekohl
Created May 3, 2010 18:52
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 ekohl/388444 to your computer and use it in GitHub Desktop.
Save ekohl/388444 to your computer and use it in GitHub Desktop.
#!/bin/sh
BASE="$HOME/videos"
get_show() {
sed 's/\(.\+\)\.[Ss][0-9]\+[Ee][0-9]\+.\+/\1/' | tr [A-Z] [a-z]
}
get_season() {
sed 's/.\+\.[Ss]\([0-9]\+\)[Ee][0-9]\+.\+/\1/'
}
copy() {
filename="$(basename -- "$1")"
show="$(echo $filename | get_show)"
season="$(echo $filename | get_season)"
target="$BASE/series/$show/$season/$filename"
mkdir -p $(dirname "$target")
test -f "$target" || cp -v "$1" "$target"
}
find "$BASE/lampje/" -regextype posix-egrep -iregex ".+\.s[0-9]+e[0-9]+\..+\.(avi|mkv)" -print | while read FILE; do
copy "$FILE"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment