rename daily series w/o checking any db

All about user-defined episode / movie / file name format expressions
Post Reply
underrepresented
Posts: 15
Joined: 15 Nov 2015, 21:38

rename daily series w/o checking any db

Post by underrepresented »

I watch several daily news shows that haven't been maintained by the databases in over 6 mths.

They seem to be always formated "commentators.title.yyyy.MM.dd.vf.type.group.mkv". i.e. All.In.with.Chris.Hayes.2018.03.28.540p.WEBDL-Anon.mkv. I would just like to strip out .vf.type.group and just name the file "commentators title yyyy MM dd.mkv" without using any of the databases.

I see in the edit preset ui "Do Select files". I presume this is where I'd do my testing but I have no clear idea what of I'm doing. I could possibly grep strip and tail in some way; but I'm a clueless old fart that is more dangerous at the keyboard than effective. Spending 5 hours over one line of code doing it the trial and error way just makes my head hurt a lot. I use a shell script within transmissionbt that I plagiarized to suit my current needs. (took me a couple of weeks trial and error to get it to work correctly) Any help you could provide would be much appreciated.

Thank you for all the help you've given your community of followers including me.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: rename daily series w/o checking any db

Post by rednoah »

It sounds like you're looking for help with Plain File mode?

Have you tried this yet?
viewtopic.php?f=3&t=2072

A format such as this will probably get the job done:

Code: Select all

{fn.before(/720p|1080p/)}
:idea: Please read the FAQ and How to Request Help.
underrepresented
Posts: 15
Joined: 15 Nov 2015, 21:38

Re: rename daily series w/o checking any db

Post by underrepresented »

that didn't work for me at all. I kept ending up with the filename truncated on itself 2-4 times depending on where I placed that piece of code. I almost got it once but it was still truncated at the end of the original name. i.e. All.In.with.Chris.Hayes.2018.03.28.540p.WEBDL-AnonAll.In.with.Chris.Hayes.2018.03.28...mkv ; with the extra periods.


but I did find this snippet worked exactly like I wanted with the UI.

Code: Select all

{n.stripReleaseInfo().space(' ')}
All In with Chris Hayes 2018 03 28.mkv

Now to try and figure out how to get it to work within my bash script that uses the amc script for everything else.
May just have to exclude those few files and always do them manually. :/
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: rename daily series w/o checking any db

Post by kim »

Maybe you can use this, and save to e.g. "OfflineRename.groovy"
*NOT TESTET*

Code: Select all

rename(map: args.getFiles()
	.findAll{ it.name =~ '(?i:All.In.with.Chris.Hayes)' }
		.each{println "FOUND: $it.name"}
			.collectEntries{
				[it, it.name.replaceFirst('(\\w.+(?:19|20)+\\d{2}.\\d{2}.\\d{2}).*$', '$1')]
			}
)
or just use this format in "F2 mode" viewtopic.php?f=3&t=2072

Code: Select all

{fn.replaceAll(/(\w.+)([\. ]\d{3}[pP].+$)/, '$1') }
or

Code: Select all

{fn.replaceAll(/(\w.+(?:19|20)+\d{2}.\d{2}.\d{2}).*$/, '$1') }
Last edited by kim on 03 May 2018, 22:25, edited 1 time in total.
underrepresented
Posts: 15
Joined: 15 Nov 2015, 21:38

Re: rename daily series w/o checking any db

Post by underrepresented »

The last two do provide the format I'd like and work very well with the UI. Don't understand how to implement the first one tho.

Been trying to insert it in the cli directly with --filter and via my format.txt file with filter=

cli

Code: Select all

	/usr/local/bin/filebot -script fn:amc --output "$FB_OUTPUT" --filter "{fn.replaceAll(/(\w.+)([\. ]\d{3}[pP].+$)/, '$1').space(' ') }" --action move --conflict skip  -non-strict --log ALL --log-file amc.log --def @"$HOME"/.filebot/_filebot_format.txt ut_dir="$FB_PATH" ut_kind="multi" ut_title="$FB_NAME" ut_label="$FB_LABEL" >> "$LOGFILE" 2>&1
this is the error I got when trying the above:

Code: Select all

Group: [tvs:the rachel maddow show] => [The.Rachel.Maddow.Show.2018.04.26.540p.WEBDL-Anon.mp4]
ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script4.groovy: 1: Ambiguous expression could be either a parameterless closure expression or an isolated open code block;
   solution: Add an explicit closure parameter list, e.g. {it -> ...}, or force it to be treated as an open block by giving it a label, e.g. L:{...} @ line 1, column 1.
   {fn.replaceAll(/(\w.+)([\. ]\d{3}[pP].+$)/, '/Volumes/Stuff/!Videos/The.Rachel.Maddow.Show.2018.04.26.540p.WEBDL-Anon/The.Rachel.Maddow.Show.2018.04.26.540p.WEBDL-Anon.mp4').space(' ') }
   ^

1 error
format.txt

Code: Select all

movieFormat=_Movies/{n.replaceTrailingBrackets()} ({y}){' CD'+pi}
seriesFormat=_TV/{n.replaceTrailingBrackets()} {s00e00} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}
animeFormat=Anime/{n}/{fn}
maxAgeDays=14
minFileSize=0
unsorted=y
music=n
artwork=n
ignore=/.nfo|/.info|/.txt|/.sample/.|/.jpg|/.jpeg|/.png|/.DS_Store
filter=_TV/{fn.replaceAll(/(\w.+)([\. ]\d{3}[pP].+$)/, '$1').space(' ') }
I haven't ran it this way yet. but am expecting an error condition.

I'm trying to get out of running filebot twice with if/then/else in bash. Don't quite understand how to do if/then/else with filebot itself.

I think I can use this to match in some way ( Rachael.Maddow|Chris.Hayes|Brian.Williams|Lawrence.O\'Donnell|Lawrence.ODonnell|Chris.Matthews|Chris.Mathews
) or even shorten it down to last names. I just don't seem to grok how and still have series and movies to work properly.

Personally I think its better to use format.txt file than trying to rewrite the whole command line out every time minor change or filter is made. Especially if you have a very complex set of commands.

On my setup everything is staged and renamed on a local usb drive and I manually move the files after they are renamed into their respective tv/movie folders. If I d/l a complete season then I use the UI to organize the series into season folders. name/name season 01/episodes.

I still catch way too many minor errors to have filebot move everything to my NASs. Tho I suppose I could create a bash script and filebot to do it after the staging is done. Thats something I'll work on later when I feel more confident with the staging aspect.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: rename daily series w/o checking any db

Post by rednoah »

--filter doesn't do what you think it does.

Actually, I don't know what you're trying to do, but the filter expression doesn't make sense to me.

What exactly are you trying to use --filter for? Maybe the --def ignore option can help you "filter out" files?
:idea: Please read the FAQ and How to Request Help.
underrepresented
Posts: 15
Joined: 15 Nov 2015, 21:38

Re: rename daily series w/o checking any db

Post by underrepresented »

well, never mind then. ignore works perfectly well and leaves files in the _rename staging area. I'll just have to live with manually renaming the files with filebot UI with one of the code lines above that kim provided. thank you for the help and great program.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: rename daily series w/o checking any db

Post by rednoah »

You can automate that part as well with command-line scripts, if it's something that you have to do repeatedly. If you prefer the GUI then Presets might also be useful, and with Presets you can have an "include expression" to automatically select only certain files.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: rename daily series w/o checking any db

Post by kim »

you need to run "OfflineRename.groovy" BEFORE or instead of "AMC"

Code: Select all

filebot -script "OfflineRename.groovy" %INPUTFOLDER%

I have now tested this and it works :D

Code: Select all

rename(map: args.getFiles()
	.findAll{ it.name =~ '(?i:All.In.with.Chris.Hayes)' }
		.each{println "FOUND: $it.name"}
			.collectEntries{
				[it, it.name.replaceFirst('(\\w.+(?:19|20)+\\d{2}.\\d{2}.\\d{2}).*$', '$1')+'.'+it.extension]
			}
)
input:
All.In.with.Chris.Hayes.2018.03.28.540p.WEBDL-Anon.mkv
output:
All.In.with.Chris.Hayes.2018.03.28.mkv
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: rename daily series w/o checking any db

Post by kim »

version 2

Code: Select all

filebot -script "OfflineRename.groovy" %INPUTFOLDER% --action move --output %OUTPUTFOLDER%

Code: Select all

rename(map: args.getFiles()
	.findAll{ it.name =~ '(?i:All.In.with.Chris.Hayes)' }
		.each{println "FOUND: $it.name"}
			.collectEntries{
				[it, _args.output+'/'+'All In with Chris Hayes'+'/'+it.name.replaceFirst('(\\w.+(?:19|20)+\\d{2}.\\d{2}.\\d{2}).*$', '$1')+'.'+it.extension]
			}
)
outputfolder\All In with Chris Hayes\All.In.with.Chris.Hayes.2018.03.28.mkv
underrepresented
Posts: 15
Joined: 15 Nov 2015, 21:38

Re: rename daily series w/o checking any db

Post by underrepresented »

kim wrote: 03 May 2018, 22:21 you need to run "OfflineRename.groovy" BEFORE or instead of "AMC"

Code: Select all

filebot -script "OfflineRename.groovy" %INPUTFOLDER%

I have now tested this and it works :D

Code: Select all

rename(map: args.getFiles()
	.findAll{ it.name =~ '(?i:All.In.with.Chris.Hayes)' }
		.each{println "FOUND: $it.name"}
			.collectEntries{
				[it, it.name.replaceFirst('(\\w.+(?:19|20)+\\d{2}.\\d{2}.\\d{2}).*$', '$1')+'.'+it.extension]
			}
)
input:
All.In.with.Chris.Hayes.2018.03.28.540p.WEBDL-Anon.mkv
output:
All.In.with.Chris.Hayes.2018.03.28.mkv
Thank you Kim.

One more question...

can I replace ?i:All.In.with.Chris.Hayes with ?i:hardball|maddow|hayes|donnell|11th

or maybe a .match(readlines(msnbc.txt)

those programs all come formatted the same way as ALL.In....
Last edited by underrepresented on 04 May 2018, 05:17, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: rename daily series w/o checking any db

Post by rednoah »

Probably, yes. Just give it a try. ;)
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: rename daily series w/o checking any db

Post by kim »

yes just like so..... btw "findAll" is the "filter"

Code: Select all

rename(map: args.getFiles()
	.findAll{ it.name =~ '(?i:All.In.with.Chris.Hayes|hardball|maddow|hayes|donnell|11th)' }
		.each{println "FOUND: $it.name"}
			.collectEntries{
				[it, it.name.replaceFirst('(\\w.+(?:19|20)+\\d{2}.\\d{2}.\\d{2}).*$', '$1')+'.'+it.extension]
			}
)
but it's better to add the full show names
underrepresented
Posts: 15
Joined: 15 Nov 2015, 21:38

Re: rename daily series w/o checking any db

Post by underrepresented »

Thank You Kim. version 2 above works quite nicely for what I want with a lil modification.

Now if I could just set a variable with the filebot output. Currently I just use ls -t on the final dir placement for the variable context. Or, I could use cat grep awk on the amc log file. but thats an exorcise in bash scripting and not filebot. : ;)
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: rename daily series w/o checking any db

Post by kim »

I don't get what you wanna do ?

If you use "version 2" then

Code: Select all

_args.output
will be whatever you write in "%OUTPUTFOLDER%"

Code: Select all

--output %OUTPUTFOLDER%
underrepresented
Posts: 15
Joined: 15 Nov 2015, 21:38

Re: rename daily series w/o checking any db

Post by underrepresented »

kim wrote: 12 May 2018, 01:57 I don't get what you wanna do ?

If you use "version 2" then

Code: Select all

_args.output
will be whatever you write in "%OUTPUTFOLDER%"

Code: Select all

--output %OUTPUTFOLDER%
no worries. I'm happy your solution worked for me. I just tweaked a lil bit by removing the series folder and the . in the names. you did everything right imo.
Post Reply