how to rename movie to [file foldername].[file ext]

Any questions? Need some help?
Post Reply
noze2000
Donor
Posts: 22
Joined: 08 Feb 2015, 20:08

how to rename movie to [file foldername].[file ext]

Post by noze2000 »

Hi all,


While I appreciate the many naming schemes available, I like to keep the scene name of the movies so I can get subtitles manually if (and when) automatic subtitles fail. I use a simple rename : {fn}

I have an automated setup and usually that works fine.

But, sometimes the file name is a short version of the scene name - and different from the folder name (which normally is always the correct scene name)

That means that the file will keep its original compressed filename and my media center has trouble picking that up

Is it possible to create a renaming scheme that sets the file name to the parent folder name (but keeps the extension of course)?

I appreciate any help here.

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

Re: how to rename movie to [file foldername].[file ext]

Post by rednoah »

Folder name:

Code: Select all

{folder.name}
Folder name or file name whichever is longer:

Code: Select all

{[fn, folder.name].max{ it.length() }}
or

Code: Select all

{fn.length() > folder.name.length() ? fn : folder.name}
:idea: Please read the FAQ and How to Request Help.
noze2000
Donor
Posts: 22
Joined: 08 Feb 2015, 20:08

Re: how to rename movie to [file foldername].[file ext]

Post by noze2000 »

This is awesome.
Thanks for a perfect answer.
/N
noze2000
Donor
Posts: 22
Joined: 08 Feb 2015, 20:08

Re: how to rename movie to [file foldername].[file ext]

Post by noze2000 »

The below seems to get what I need.
BUT, it now renames also the subtitles to a separate folder..

So if movie name is 123.mkv and subtitles 123.eng.srt exists, these are renamed to two different folders:
movies/123/123.mkv
movies/123.eng/123.eng.srt

Can that be fixed or do I need to do subtitles outside of amc?

Thanks!

Code: Select all

filebot -script fn:amc --output "/share/Disk1" --action move  -non-strict "/share/Download/lowresmovies" --log-file /share/Disk1/amc.log --def excludeList=amc.txt --def clean=y --def movieFormat="/share/Disk8/lowresmovies/{fn.length() > folder.name.length() ? fn.upperInitial() : folder.name.upperInitial().space('.')}/{fn.upperInitial().space('.')}" --def subtitles=en --def deleteAfterExtract=y -non-strict
noze2000
Donor
Posts: 22
Joined: 08 Feb 2015, 20:08

Re: how to rename movie to [file foldername].[file ext]

Post by noze2000 »

Ok so I have no knowledege in regEx but here goes:
I'm adding

Code: Select all

.replaceall('\.Eng$', '')
to the naming scheme..

Code: Select all

filebot -script fn:amc --output "/share/Disk1" --action move  -non-strict "/share/Disk8/lowresmovies" --log-file /share/Disk1/amc.log --def excludeList=amc.txt --def clean=y --def movieFormat="/share/Disk8/temp/{fn.length() > folder.name.length() ? fn.upperInitial().space('.').replaceall('\.Eng$', '') : folder.name.upperInitial().space('.')}/{fn.upperInitial().space('.')}" --def subtitles=en --def deleteAfterExtract=y -non-strict
Output: It does not like my escape character "\":

Log:

Code: Select all

Run script [fn:amc] at [Fri Aug 19 21:30:04 GMT 2016]
Parameter: excludeList = amc.txt
Parameter: clean = y
Parameter: movieFormat = /share/Disk8/temp/{fn.length() > folder.name.length() ? fn.upperInitial().space('.').replaceall('\.Eng$', '') : folder.name.upperInitial().space('.')}/{fn.upperInitial().space('.')}
Parameter: subtitles = en
Parameter: deleteAfterExtract = y
Argument: /share/HDH_DATA/Disk8/lowresmovies
Creating excludes: /share/HDA_DATA/Disk1/amc.txt
Input: /share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt
Input: /share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi
xattr: [My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt] => [My Guardian Angel (2016)]
xattr: [My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi] => [My Guardian Angel (2016)]
Group: [mov:my guardian angel 2016] => [My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt, My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi]
No missing subtitles
SyntaxError: unexpected char: '\'
javax.script.ScriptException: SyntaxError: unexpected char: '\'
	at net.filebot.format.ExpressionFormat.compile(ExpressionFormat.java:117)
	at net.filebot.format.ExpressionFormat.<init>(ExpressionFormat.java:75)
	at net.filebot.cli.CmdlineOperations.rename(CmdlineOperations.java:97)
	at net.filebot.cli.ScriptShellBaseClass.rename(ScriptShellBaseClass.java:336)
	at Script1$_run_closure73.doCall(Script1.groovy:401)
	at Script1.run(Script1.groovy:364)
	at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:62)
	at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:72)
	at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:114)
	at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:29)
	at net.filebot.Main.main(Main.java:120)
Clean clutter files and empty folders
Finished without processing any files
Failure (°_°)
And if I do it without the "\" then the subtitle file simply gets moved in the parent directory (I think that's because the . functions like a * ?

log:

Code: Select all

Run script [fn:amc] at [Fri Aug 19 21:33:10 GMT 2016]
Parameter: excludeList = amc.txt
Parameter: clean = y
Parameter: movieFormat = /share/Disk8/temp/{fn.length() > folder.name.length() ? fn.upperInitial().space('.').replaceall('.Eng$', '') : folder.name.upperInitial().space('.')}/{fn.upperInitial().space('.')}
Parameter: subtitles = en
Parameter: deleteAfterExtract = y
Argument: /share/HDH_DATA/Disk8/lowresmovies
Creating excludes: /share/HDA_DATA/Disk1/amc.txt
Input: /share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt
Input: /share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi
xattr: [My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt] => [My Guardian Angel (2016)]
xattr: [My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi] => [My Guardian Angel (2016)]
Group: [mov:my guardian angel 2016] => [My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt, My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi]
No missing subtitles
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi]
[MOVE] Rename [/share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi] to [/share/Disk8/temp/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.avi]
[MOVE] Rename [/share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG/My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt] to [/share/Disk8/temp/My.Guardian.Angel.2016.HDRip.XViD-ETRG.Eng.srt]
Processed 2 files
Clean clutter files and empty folders
Delete /share/HDH_DATA/Disk8/lowresmovies/My.Guardian.Angel.2016.HDRip.XViD-ETRG
Done ヾ(@⌒ー⌒@)ノ

 
Any help with this would be appreciated :)
noze2000
Donor
Posts: 22
Joined: 08 Feb 2015, 20:08

Re: how to rename movie to [file foldername].[file ext]

Post by noze2000 »

and I figured it out..not sure what is the difference:

Code: Select all

filebot -script fn:amc --output "/share/Disk1" --action test  -non-strict "/share/Disk8/lowresmovies" --log-file /share/Disk1/amc.log --def clean=y --def movieFormat="/share/Disk8/temp/{fn.length() > folder.name.length() ? fn.upperInitial().space('.').replaceAll(/\.Eng$/,'').replaceAll(/\.En$/,'').replaceAll(/\.en$/,'').replaceAll(/\.En$/,'') : folder.name.upperInitial().space('.')}/{fn.upperInitial().space('.')}" --def subtitles=en --def deleteAfterExtract=y -non-strict
Post Reply