-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload
More file actions
executable file
·31 lines (27 loc) · 1.09 KB
/
upload
File metadata and controls
executable file
·31 lines (27 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash -x
#move allowed files from torrent folder
find /var/downloads -regextype posix-egrep -regex '.*\.(avi|m2ts|flv|M2TS|3gp|AVI|MPG|mkv|MKV|ogv|wmv|WMV|mp4|mpg|divx|MPG|mpeg|ogg|ogm)$' -exec mv "{}" /var/fix/ \;
sleep 1
#fix ugly file names
cd /var/fix
for f in *; do mv -- "$f" "${f//[][(){\}]}"; done
sleep 1
#correct ugly file names
cd /var/fix
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/fix/$NEWFILE5";
done;
sleep 1
#here we use megatools from debian sid, to sync local directory of files to remote mega.co.nz account
find /var/fix -regextype posix-egrep -regex '.*\.(avi|m2ts|flv|M2TS|3gp|AVI|MPG|mkv|MKV|ogv|wmv|WMV|mp4|mpg|divx|MPG|mpeg|ogg|ogm)$' -exec megasync --local /var/fix --remote /Root \; && rm -rf /var/fix/*