Only rename files using an AMC script

Support for Synology NAS, QNAP NAS and other Embedded Linux systems
Post Reply
redoXiD
Posts: 6
Joined: 14 Apr 2022, 21:52

Only rename files using an AMC script

Post by redoXiD »

Hi there,

I'm currently trying to automate my SABnzbd setup running on my QNAP NAS using an FileBot AMC bash script.
So far, the script looks like this (WIP):

Code: Select all

#!/bin/bash

# SABnzbd Post Processing Script - www.Filebot.net "AMC" Script

FILE_PATH=$1
FILE_NAME=$3

filebot -script \
   fn:amc \
   --output "$FILE_PATH" \
   --action move \
   --conflict override -non-strict \
   --def music=n \
   --encoding UTF-=8 \
   --def "exts=jpg|nfo|srv|srr|nzb|sfv|idx|sub|txt|part01|part02|par1|par2|info|com|db|md5|1|jpeg|url|lnk|html|ini|bat|com|exe|scr|sample" \
   --db TheMovieDB::TV \
   --lang German \
   --format "{n.colon(' - ')} - {s00e00} - {t.colon(' - ')} - {vf}{' CD'+pi}{any{subt}{f.subtitle ? fn =~ /forced/ ? '.ger.forced' : '.ger' : null}}" \
   --def "ut_dir=$FILE_PATH" \
   --def "ut_title=$FILE_NAME"
The problem is that the output of the script says "output folder [...] must not be inside input folder [...] and vice versa".

I know that the problem is caused by having the same input and output folder, but that is actually what I want to achieve as I only want to rename the files and want them to remain in the original folder (e.g. "Moon.Knight.S01E04.German.DL.Webrip.x264-TVARCHiV/*"), moving the folder to its final location is already achieved by SABnzbd.
As far as I know, this wouldn't be possible with a different output folder in the script. Another problem is that (using a different output folder) the files I don't want to rename (nfo, jpg, png, txt, sample etc.) would not be moved to the new folder, even though I would like to keep them in the folder with the other files.
(So basically I want to reproduce the same behavior of my custom format like it would have in the GUI)

Is there any solution that would work for me? Additional bash scripts etc. would of course also do the job.
User avatar
rednoah
The Source
Posts: 20925
Joined: 16 Nov 2011, 08:59

Re: Only rename files using an AMC script

Post by rednoah »

The amc script cannot be used to only rename files. It's just not made for that use case.


:idea: You could add --apply import to copy along companion files:
viewtopic.php?t=12172


:arrow: You'll probably want to do a simple filebot -rename call tailored to your specific use case:
https://www.filebot.net/cli.html
:idea: Please read the FAQ and How to Request Help.
redoXiD
Posts: 6
Joined: 14 Apr 2022, 21:52

Re: Only rename files using an AMC script

Post by redoXiD »

Thank you for the tip, apparently I was thinking way too complicated. Using the -rename everything works as expected!

This is what my new format looks like:

Code: Select all

filebot -rename -r "$1" --db TheMovieDB::TV -non-strict --lang German \
   --conflict override -non-strict \
   --encoding UTF-=8 \
   --format "{n.colon(' - ')} - {s00e00} - {t.colon(' - ')} - {vf}{' CD'+pi}{any{subt}{f.subtitle ? fn =~ /forced/ ? '.ger.forced' : '.ger' : null}}"
One last thing I stumbled accross is how to exclude files from renaming. I've already read How to process only specific kinds of files?, but I don't really understand how to apply that to my custom script. Specifically, I want to exclude nfo, jpg, png, sample and trailer files from renaming.
Are there any tips you could give me?

EDIT: I think I figured it out, I just forgot to add the quotes when I added this part:

Code: Select all

--file-filter "none{ ext =~ /jpg|png|nfo|txt/ }{ fn.match(/sample|trailer/) }{ f =~ /Extras|Featurettes/ }"
User avatar
rednoah
The Source
Posts: 20925
Joined: 16 Nov 2011, 08:59

Re: Only rename files using an AMC script

Post by rednoah »

Note that --encoding UTF-=8 does nothing. Best to remove options that don't do anything as to not confuse yourself and others. The -= is probably a typo on top of that but since filebot -rename doesn't use the --encoding option you won't get any complaints about that.
:idea: Please read the FAQ and How to Request Help.
Post Reply