Skip to content

Instantly share code, notes, and snippets.

@mgallego
Created July 4, 2015 13:50
Show Gist options
  • Save mgallego/61def3a405d9dae0fcc4 to your computer and use it in GitHub Desktop.
Save mgallego/61def3a405d9dae0fcc4 to your computer and use it in GitHub Desktop.
Transmission script for get the videos from a downloaded torrent and move to a new directory
#!/bin/sh
SOURCEDIR='/downloaded/torrents/directory/absolute/path'
TARGETDIR='/target/directory/absolute/path/'
counter=0
find $SOURCEDIR -type f -exec file -N -i -- {} + | sed -n 's!: video/[^:]*$!!p' | while read -r file
do
output=$(date +"%s")-${counter}_${file##*/}
mv "${file}" "${TARGETDIR}/${output}"
counter=$((counter+1))
done
rm -rf "${TR_TORRENT_DIR}/${TR_TORRENT_NAME}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment