regex - regex filename pattern
Posted: Fri Sep 07, 2012 8:24 pm
my bash script on download complete, it fires this bash script to fix bad file pattern which are not compatible on the terminal, this bash replaces white space with _ underscore
tested on Transmission 2.51 (13280) ubuntu 12.04 64bit works
stop bt daemon
/etc/init.d/transmission-daemon stop
make folders
create empty sh like this in terminal
nano regex.sh
past this inside
open the settings.json and edit like this
now,
and finally reboot your Server
type this in terminal
thats it, its working perfectly for me
hope it helps somebody
tested on Transmission 2.51 (13280) ubuntu 12.04 64bit works
stop bt daemon
/etc/init.d/transmission-daemon stop
make folders
Code: Select all
mkdir /var/www/tmp
mkdir /var/www/downloads ---- < point your transmission download complete folder here
Code: Select all
chmod 755 /var/www/tmp
chmod 755 /var/www/downloads
chmod 755 /var/www/regex.sh
nano regex.sh
past this inside
Code: Select all
#!/bin/bash
chmod 777 /var/www/downloads/*
sleep 5
find /var/www/downloads -regextype posix-egrep -regex '.*\.(avi|mkv|ogv|mp4)$' -exec mv "{}" /var/www/tmp/ \;
sleep 5
rm -rf /var/www/downloads/*
sleep 5
cd /var/www/tmp
for infile in *.*;
do
#replace " - " with a single underscore.
NEWFILE1=`echo $infile | sed 's/\s-\s/_/g'`;
#replace spaces with underscores
NEWFILE2=`echo $NEWFILE1 | sed 's/\s/_/g'`;
#replace "-" dashes with underscores.
NEWFILE3=`echo $NEWFILE2 | sed 's/-/_/g'`;
#remove exclamation points
NEWFILE4=`echo $NEWFILE3 | sed 's/!//g'`;
#remove commas
NEWFILE5=`echo $NEWFILE4 | sed 's/,//g'`;
mv "$infile" "/var/www/downloads/$NEWFILE5";
done;
open the settings.json and edit like this
Code: Select all
nano /var/lib/transmission-daemon/info/settings.json
Code: Select all
"download-dir": "/var/www/downloads",
Code: Select all
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "var/www/regex.sh",
now,
Code: Select all
/etc/init.d/transmission-daemon reload
Code: Select all
/etc/init.d/transmission-daemon restart
type this in terminal
Code: Select all
reboot
thats it, its working perfectly for me

hope it helps somebody