How to customize AMC file renaming?

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
Post Reply
Silvercloak
Posts: 14
Joined: 12 May 2018, 01:46

How to customize AMC file renaming?

Post by Silvercloak » 03 Jan 2019, 19:54

I'm a bit baffled as to how the file renaming works in the AMC. Right now it gives me show title, season number, episode number, and episode name - all in mixed case. So it would be like this

The Good Place - S03E10 - Episode Name.mkv

I want it to be like;

the.good.place.s03e10.episode.name.mkv

Is this possible? I'm having issues with my scraper in Kodi and this might fix it.

Thanks - I'm using the utorrent-postprocess.pyw file as outlined in the Automation setup post.

Silvercloak

Silvercloak
Posts: 14
Joined: 12 May 2018, 01:46

Re: How to customize AMC file renaming?

Post by Silvercloak » 03 Jan 2019, 20:37

Or even better yet - don't rename a thing, just move the file in the appropriate directory. How do I fix the python script for that? I'm reading it but I can make no sense of it.

Code: Select all

# Run Program: 
# "C:\path\to\utorrent-postprocess.pyw" "%L" "%S" "%N" "%K" "%F" "%D"
#
# Test with Console:
# python "C:\path\to\utorrent-postprocess.pyw" "Movie" "5" "Avatar" "multi" "" "X:\Files\Avatar"


import sys
import subprocess


# configuration
output = 'E:/Media'


# custom formats (use / instead of \ as directory separator)
movieFormat  = '''{plex}'''
seriesFormat = '''{plex}'''
animeFormat  = '''{plex}'''
musicFormat  = '''{plex}'''


# required args
label, state, title, kind, file, directory = sys.argv[1:7]


command = [
	'filebot', '-script', 'fn:amc',
	'--output', output,
	'--action', 'duplicate',
	'--conflict', 'skip',
	'-non-strict',
	'--log-file', 'C:/Logs/amc.log',
	'--def',
		'unsorted=y',
		'music=y',
		'artwork=y',
		'movieFormat='  + movieFormat,
		'seriesFormat=' + seriesFormat,
		'animeFormat='  + animeFormat,
		'musicFormat='  + musicFormat,
		'ut_label=' + label,
		'ut_state=' + state,
		'ut_title=' + title,
		'ut_kind='  + kind,
		'ut_file='  + file,
		'ut_dir='   + directory
]


# execute command only for certain conditions (disabled by default)
'''
if state not in ['5', '11']:
	print('Illegal state: %s' % state)
	sys.exit(0)
'''


# execute command (and hide cmd window)
subprocess.run(command, creationflags=0x08000000)

User avatar
rednoah
The Source
Posts: 16416
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize AMC file renaming?

Post by rednoah » 04 Jan 2019, 08:25

Silvercloak wrote:
03 Jan 2019, 19:54
the.good.place.s03e10.episode.name.mkv

Is this possible? I'm having issues with my scraper in Kodi and this might fix it.
Yes, it's possible. No, less well-named files probably won't make Kodi work better.


1.
The Change how files will be organized and renamed section explains how you can plug in your own custom formats into the amc script if you don't like the default {plex} format:
viewtopic.php?f=4&t=215


2.
You'll want to ask the Kodi community for help on how to figure out why Kodi isn't working well for you though:
https://forum.kodi.tv/
:idea: Please read the FAQ and How to Request Help.

Silvercloak
Posts: 14
Joined: 12 May 2018, 01:46

Re: How to customize AMC file renaming?

Post by Silvercloak » 04 Jan 2019, 16:38

I'm confused. I've gone over that link a few times and I'm not sure where it shows how to change the renaming format. Sorry if I'm a bit dense but I just don't see it.

Silvercloak

User avatar
rednoah
The Source
Posts: 16416
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize AMC file renaming?

Post by rednoah » 05 Jan 2019, 05:51

If you're not yet familiar with FileBot format expressions, then it's best to fire up the Format Editor GUI to play with it for a few minutes:
https://www.filebot.net/naming.html

e.g. this code:

Code: Select all

{n.lower().space('.')}.{s00e00.lower()}.{t.lower().space('.')}
will yield destination file names such as this:

Code: Select all

firefly.s01e01.serenity
Since you're organizing files into a new file structure, you can do that as well, with more of the same:

Code: Select all

X:/{n.lower().space('.')}/season.{s}/{n.lower().space('.')}.{s00e00.lower()}.{t.lower().space('.')}
If you are happy with your custom format in the GUI editor, then you can just copy & paste it into your FileBot command:

Code: Select all

--def seriesFormat="X:/{n.lower().space('.')}/season.{s}/{n.lower().space('.')}.{s00e00.lower()}.{t.lower().space('.')}"
Since you're using the Python script, there's a configuration line for your convince at the top of the script, which is then used the pass in the appropriate command-line arguments:

Code: Select all

seriesFormat = '''X:/{n.lower().space('.')}/season.{s}/{n.lower().space('.')}.{s00e00.lower()}.{t.lower().space('.')}'''

:!: Note that this kind of advanced configuration and customization will not help in any way at all if the goal is to make Kodi scrapers work. This kind of configuration is for users that just want their things named in a certain way for their own convenience. If you're using Plex or Kodi, then the defaults will work best.
:idea: Please read the FAQ and How to Request Help.

Silvercloak
Posts: 14
Joined: 12 May 2018, 01:46

Re: How to customize AMC file renaming?

Post by Silvercloak » 06 Jan 2019, 16:35

Trust me, the defaults ARENT working in Kodi. I've talked with others on Kodi forums, the scrapers for Kodi have changed in June of 2018. Special characters and spaces will confused the scraper. Which is why I'm dumbing it down as much as possible.

Thanks for all those, I'll give your python script code a shot.

For code #1 up there, is that a groovy script code? And #3?

As well in #4, I don't understand where these --def things are supposed to be placed. In the command line? Groovy? Python? None of these have been very clearly laid out. Unfortunately Filebot seems to be geared more to those proficient with various types of coding. It makes it difficult for the average person to understand.

Thanks for your help! Hopefully this will solve my problems. :)

Silvercloak

User avatar
rednoah
The Source
Posts: 16416
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize AMC file renaming?

Post by rednoah » 06 Jan 2019, 17:10

The code with lots of {...} {...} {...} is FileBot format code. The first is a format for the file name only. The second is a format for an absolute path.

--def name=value pairs are FileBot command-line options. Since you're using the Python script, you probably don't need to worry, because you're executing the command from Python. The Python script itself is mostly about building a command to execute, so it's simple but only makes sense if you have used FileBot on the command-line before.

Most of it is just copy & paste. It'll make sense if spend a little bit of time looking at the examples and playing around.
:idea: Please read the FAQ and How to Request Help.

Silvercloak
Posts: 14
Joined: 12 May 2018, 01:46

Re: How to customize AMC file renaming?

Post by Silvercloak » 06 Jan 2019, 17:17

I did! Thank you - it worked at renaming everything into lowercase. We'll see how it goes with Kodi now. Thanks so much for your help!

User avatar
rednoah
The Source
Posts: 16416
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize AMC file renaming?

Post by rednoah » 07 Jan 2019, 12:47

Please report back with what works best for Kodi. If {plex} doesn't work, then I also have no idea what Kodi might like or have trouble with.
:idea: Please read the FAQ and How to Request Help.

Silvercloak
Posts: 14
Joined: 12 May 2018, 01:46

Re: How to customize AMC file renaming?

Post by Silvercloak » 07 Jan 2019, 16:10

Maddeningly - no it didn't work. I'm absolutely stumped now. I even did a full wipe and reinstall of Kodi. TVDB scrapes absolutely NOTHING. XEM is only a partial success. I give up. I'm done with Kodi, I'm just using it to Launch it's Plex Add On from now on. I'm baffled.

User avatar
rednoah
The Source
Posts: 16416
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: How to customize AMC file renaming?

Post by rednoah » 07 Jan 2019, 16:17

rednoah wrote:
04 Jan 2019, 08:25
No, less well-named files probably won't make Kodi work better.
I suppose we have to learn these things for ourselves. :lol: :roll: Plenty of options there though, Plex has it's issues, but at least they have one single set of standardized naming rules.
:idea: Please read the FAQ and How to Request Help.

kim
Power User
Posts: 796
Joined: 15 May 2014, 16:17

Re: How to customize AMC file renaming?

Post by kim » 08 Jan 2019, 15:21

If you are using AMC to rename, why not make it make the "tvshow.nfo" also
then KODI will get the correct show.

if you want the episode nfo's also you can use my custom version:
viewtopic.php?f=4&t=5451&p=31192#p31191

I use KODI in "offline mode" (no need to scrape/download more) and if Filebot does it's work correct I never have any problem with KODI

Silvercloak
Posts: 14
Joined: 12 May 2018, 01:46

Re: How to customize AMC file renaming?

Post by Silvercloak » 08 Jan 2019, 16:05

Cool - thanks, I'll look into that!

Post Reply