[HELP] Can't figure out where the path comes from

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
minimadsen
Posts: 7
Joined: 27 Feb 2013, 00:16

[HELP] Can't figure out where the path comes from

Post by minimadsen »

Hi,
First, thanks for a great program. Donated a bit to the purchase of the website, and I hope it comes together for you
I have a small problem with my groovy script. Have stolen a bit from the sortivo and the sorty scripts.
My problem is that although I have defined the episodeDir, it always puts in in episodeDir/TV Shows/{show}/Season xx/episodeFormat
How can I get rid of the "TV Shows/{show}/Season xx/" bit?
It is probably something really simple, and comes down to my lack of understanding...
Help is much appreciated!

edit: Here is the output:

Code: Select all

Input: /home/henrik/filebotexp/Mr Selfridge - 01x08 - Episode 8.mp4
Mr Selfridge - 01x08 - Episode 8.mp4 [series: Mr Selfridge, movie: null]
Rename episodes using [TheTVDB]
Auto-detected query: [Mr Selfridge]
Fetching episode data for [Mr Selfridge]
[MOVE] Rename [/home/henrik/filebotexp/Mr Selfridge - 01x08 - Episode 8.mp4] to [TV Shows/Mr Selfridge/Season 1/Mr Selfridge - S01E08 - Episode 8.mp4]
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ
And then I get this error message:
Failed to write xattr: java.io.File.toPath()Ljava/nio/file/Path;


Code: Select all

// filebot -script fn:sortivo <folder> --output path/to/folder [-non-strict]
def episodeDir    = '''~/filebotexp/comp'''
def episodeFormat = '''~/filebotexp/comp/{episode}'''

// process only media files
def input = args.getFiles{ it.isVideo() || it.isSubtitle() }

// ignore clutter files
input = input.findAll{ !(it.path =~ /\b(?i:sample|trailer|extras|deleted.scenes|music.video|scrapbook)\b/) }

// print input fileset
input.each{ println "Input: $it" }

/*
 * Move/Rename a mix of episodes and movies that are all in the same folder.
 */
def groups = input.groupBy{ f ->
        def tvs = detectSeriesName(f)
        def mov = (parseEpisodeNumber(f) || parseDate(f)) ? null : detectMovie(f, false) // skip movie detection if we can already tell it's an episode

        // DECIDE EPISODE VS MOVIE (IF NOT CLEAR)
        if (tvs && mov) {
                def norm = { s -> s.lower().space(' ') }
                def fn = norm(f.nameWithoutExtension)
                def sn = norm(tvs)
                def mn = norm(mov.name)

                // S00E00 | 2012.07.21 | One Piece 217 | Firefly - Serenity | [Taken 1, Taken 2, Taken 3, Taken 4, ..., Taken 10]
                if (parseEpisodeNumber(fn, true) || parseDate(fn) || (fn =~ sn && parseEpisodeNumber(fn.after(sn), false)) || fn.after(sn) =~ / - .+/ || f.dir.listFiles{ $
                        println "Exclude Movie: $mov"
                        mov = null
                } else if ((detectMovie(f, true) && fn =~ /(19|20)\d{2}/) || (fn =~ mn && !(fn.after(mn) =~ /\b\d{1,3}\b/))) {
                        println "Exclude Series: $tvs"
                        tvs = null
                }
        }

        return [tvs:tvs, mov:mov]


groups.each{ group, files ->
        // EPISODE MODE
        if (group.tvs && !group.mov) {
//              rename(file:files, format:'{n} - {episode.special ? "S00E"+special.pad(2) : s00e00} - {t}', db:'TheTVDB')
                rename(file:files, format:episodeFormat, db:'TheTVDB', output:episodedir)
        }

        // MOVIE MODE
        if (group.mov && !group.tvs) {
                rename(file:files, format:'Movies/{n} ({y})/{n} ({y}){" CD$pi"}', db:'TheMovieDB')
        }
}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [HELP] Can't figure out where the path comes from

Post by rednoah »

That doesn't make sense, by the second rename the files are already gone...

Code: Select all

rename(file:files, format:'{n} - {episode.special ? "S00E"+special.pad(2) : s00e00} - {t}', db:'TheTVDB')
rename(file:files, format:episodeFormat, db:'TheTVDB', output:episodedir)
That "TV Shows" isn't in there. You sure this is the script you're calling?

EDIT:
You do now that fn:sortivo means http://filebot.sourceforge.net/scripts/sortivo.groovy right? If you want to run your local script you have to specify your local path:

Code: Select all

filebot -script ~/mysortivo.groovy ...
:idea: Please read the FAQ and How to Request Help.
minimadsen
Posts: 7
Joined: 27 Feb 2013, 00:16

Re: [HELP] Can't figure out where the path comes from

Post by minimadsen »

Thanks for the response!
The command I use is:
filebot -script fn:sortivo ~/filebotexp/

I run it from my home dir, where the only .groovy file is that file. I don't get it either...

The first of the two lines you are referring to is commented out with the //
I have deleted it now, just to avoid any confusion... If I put any path or change the fn:xxx bit, it tries to look on the net to find the script. But when I run it like above, it finds the script, so I can only assume that it is the right script.
oh... I tried copying the file to henrik.groovy and then run
filebot -script fn:henrik ~/filebotexp/
and that failed... Is it not by default looking in the dir it is being run from?
I get an error saying
FileNotFoundException: http://filebot/sourceforge.net/scripts/henrik.groovy
minimadsen
Posts: 7
Joined: 27 Feb 2013, 00:16

Re: [HELP] Can't figure out where the path comes from

Post by minimadsen »

And then I saw that I need to do -script ./henrik.groovy instead of fn:henrik.groovy
So at least now I'm going somewhere :-)

Sorry for that rookie mistake...
Post Reply