Ok, I got it.
Now I use the "rollback" function instead of moving/renaming manually the files..
I 've an another question,
How do I exclude some files extension to be processed ?
My script check .URL files and sometime .rar files as well and I don't want this files, only .mkv etc.
Or, perhaps, instead of excluding some files type we can
only process certain files type ?
I don't know how to do it with my script.
I've read some posts that talk about exclude or restrict files type but I don't understand how to implement it.
I found this :
http://www.filebot.net/forums/viewtopic.php?f=3&t=2127
That would be perfect, but I can't find the correct syntax for "exclude files type" or "restrict files type"
Here is my script :
It's a simple bash script, it's pretty locked to my needs but I'm working on it.
It's not perfect but it work for me
Code: Select all
#! /bin/bash
#############
MODE='test' # move : effective run; test : dry run
FOLDER='all' # void;MOVIESHD;MOVIES3D;ANIMATION;CARTOONS;TVSHOWS
input='/' # root directory to scan
output='/' # root directory to move/rename
#############
# link folders to scan and db : [dir-name]='db-name'
declare -A dir_db=( [MOVIESHD]='IMDb' [MOVIES3D]='IMDb' [ANIMATION]='IMDb' [CARTOONS]='IMDb' [TVSHOWS]='thetvdb' )
# renaming scheme for movies
schemeHD="{any{'_FOLDER_SAGA/'+collection.replaceAll(/[\`´‘’?\"\"“”!?.,<<>>]/,'').sortName().replaceAll(', The',',The').replaceAll(/[|:*\s]+/,'_').ascii()+'/'}{'_FOLDER/'}}{norm={it.replaceAll(/[\`´‘’?\"\"“”!?.,<<>>]/,'').sortName().replaceAll(', The',',The').upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[|:*\s]+/,'_').replaceAll(/\b[IiVvXx]+\b/,{it.upper()}).replaceAll(/\b[0-9](?i:th|nd|rd)\b/,{it.lower()}).ascii()};find3d={it.contains('[3D-SBS]')?'[3D-SBS]':it.contains('[3D-OU]')?'[3D-OU]':''};norm(primaryTitle)}_({y})/{norm(primaryTitle)}_({y}){find3d(fn)}{'['+audios.groupBy{it.Codec}.collect{c,a->[c]+a*.Language}.flatten().join('-')+']'}{'['+texts.language.flatten().join('-')+']'}{'Part'{pi}}[{allOf{vf}{vc}{source}{sdhd} join '-'}]"
# renaming scheme for tvshows
schemeTV="{'_FOLDER/'}{norm={it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[\`´‘’?\"\"“”!?.,<<>>]/,'').replaceAll(/[:|]/,'-').replaceAll(/[|:*\s]+/,'_').replaceAll(/\b[IiVvXx]+\b/,{it.upper()}).replaceAll(/\b[0-9](?i:th|nd|rd)\b/,{it.lower()}).ascii()};norm(primaryTitle)}/{episode.special?'Special_':'Season_'+s.pad(2)}_({episodelist.findAll{it.season==s}.airdate.year[0,-1].unique().join('-')})/{norm(n)}-{episode.special?'S00E'+special.pad(2):s00e00.replaceAll(/[|:*\s]+/,'')}-{norm(t).ascii().replaceAll(/[*\s]+/,'')}{'-'+lang}{'Part'{pi}}[{allOf{vf}{vc}{source}{sdhd} join '-'}]"
# link db and scheme [db-name]=$scheme-name
declare -A db_schemes=( [IMDb]=$schemeHD [thetvdb]=$schemeTV )
while getopts a:f:i:o: option
do
case "${option}"
in
a) MODE=${OPTARG};;
f) FOLDER=${OPTARG};;
i) input=${OPTARG};;
o) output=${OPTARG};;
esac
done
log=$input # directory to save logs
# scan and move/rename each folders of input to output, non-matched files will be ignored, then clean input directory
for dir in "${!dir_db[@]}";
do
if [ "$FOLDER" == "all" ] || [ "$FOLDER" == "$dir" ] && [ "$(ls -A "$input/$dir/")" ]; then
# change _folder in scheme
db_schemes[${dir_db[$dir]}]=${db_schemes[${dir_db[$dir]}]//_FOLDER/$dir};
# go filebot!
filebot --action $MODE -rename $input/$dir/ -r -non-strict --db ${dir_db[$dir]} --log all --log-file $log/.$dir.log --conflict override --output $output/ --format "${db_schemes[${dir_db[$dir]}]}";
# cleaner
filebot --action $MODE -script $input/EXTRACTED/cleaner.groovy --log all --log-file $log/.$dir.log $input/$dir/;
fi
done