Page 1 of 1

Re: Can renamed file be 'un-renamed' ?

Posted: 14 Mar 2019, 08:03
by rednoah
1.
If you have renamed the files with FileBot then you can just revert the filenames using the history feature.


2.
If you want to simply rename files based on their media title property, then you can just do that.

Please read the following threads for details on that:
viewtopic.php?f=3&t=2072
viewtopic.php?f=5&t=4285

e.g.

Code: Select all

filebot -rename /files --db file --format {mediaTitle}

Re: Can renamed file be 'un-renamed' ?

Posted: 29 May 2019, 23:57
by devster
As far as I could gather FIleBot also stores the filename in user.net.filebot.filename extended attribute.
However I've noticed that whenever I process again the same file this attribute changes.

Code: Select all

# 1st rename
user.net.filebot.filename="captive.state.2019.720p.bluray.x264-mayhem.mkv"
Output: Captive Stete (2019) [720p x264 - 5.1 DTS Eng - BluRay]-MAYHEM.mkv

# 2nd rename - maybe I changed formats and want to rename old movies
user.net.filebot.filename="Captive Stete (2019) [720p x264 - 5.1 DTS Eng - BluRay]-MAYHEM.mkv"
Output: Captive Stete (2019).mkv
I would personally prefer to always keep the first and original filename here, for reference purposes.
I will always be able to recover the original name should something go wrong with one of the formats.

Re: Can renamed file be 'un-renamed' ?

Posted: 30 May 2019, 01:15
by rednoah
FileBot shouldn't override the original filename attribute if it already exists. That's how it works now and that's how it's always been working.

e.g.

Code: Select all

filebot --rename Alias.1x01.mp4 --format "{plex.name}" -non-strict
[MOVE] from [Alias.1x01.mp4] to [Alias - S01E01 - Truth Be Told.mp4]

Code: Select all

filebot -script fn:xattr .
Alias - S01E01 - Truth Be Told.mp4
	net.filebot.filename: Alias.1x01.mp4
	...

Code: Select all

filebot -rename *.mp4 --format "{kodi.name}" -non-strict
[MOVE] from [Alias - S01E01 - Truth Be Told.mp4] to [Alias - 1x01 - Truth Be Told.mp4]

Code: Select all

filebot -script fn:xattr .
Alias - 1x01 - Truth Be Told.mp4
	net.filebot.filename: Alias.1x01.mp4
	...

Re: Can renamed file be 'un-renamed' ?

Posted: 30 May 2019, 01:59
by rednoah
I've only tested on Windows and Mac. Maybe something works differently on Linux. I'll look into it.

Re: Can renamed file be 'un-renamed' ?

Posted: 30 May 2019, 10:15
by rednoah
What do you get for files with and without original name xattr on Linux?

You can test using this script:

Code: Select all

def f = /path/to/file' as File
def m = new net.filebot.media.MetaAttributes(f)

def on = m.originalName

println on
println on.class

Re: Can renamed file be 'un-renamed' ?

Posted: 30 May 2019, 15:56
by devster

Code: Select all

# touch and rename Captive State (2019).mkv
$ filebot -script /scripts/xattr-test.groovy
captive.state.2019.720p.bluray.x264-mayhem.mkv
class java.lang.String
Done ヾ(@⌒ー⌒@)ノ
$ touch 'captive.state.2019.720p.bluray.x264-mayhem.mkv'
$ filebot -script /scripts/xattr-test.groovy
null
Cannot get property 'class' on null object
java.lang.NullPointerException: Cannot get property 'class' on null object
	at Script1.run(Script1.groovy:7)
	at net.filebot.cli.ScriptShell.evaluate(ScriptShell.java:64)
	at net.filebot.cli.ScriptShell.runScript(ScriptShell.java:74)
	at net.filebot.cli.ArgumentProcessor.runScript(ArgumentProcessor.java:163)
	at net.filebot.cli.ArgumentProcessor.run(ArgumentProcessor.java:37)
	at net.filebot.Main.main(Main.java:132)

Error (o_O)
I only seem to be able to reproduce it on NTFS-3G on Linux ARM, probably a niche bug.

Code: Select all

$ touch 'captive.state.2019.720p.bluray.x264-mayhem.mkv'
$ filebot -rename --db TheMovieDB --action move --format '{ny} {director}' captive.state.2019.720p.bluray.x264-mayhem.mkv
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/mnt/bellatrix/downloads/test/captive.state.2019.720p.bluray.x264-mayhem.mkv]
[MOVE] from [/mnt/bellatrix/downloads/test/captive.state.2019.720p.bluray.x264-mayhem.mkv] to [/mnt/bellatrix/downloads/test/Captive State (2019) Rupert Wyatt.mkv]
Processed 1 files
$ filebot -script ./xattr.groovy
captive.state.2019.720p.bluray.x264-mayhem.mkv
class java.lang.String
Done ヾ(@⌒ー⌒@)ノ

$ filebot -rename --db TheMovieDB --action move --format '{ny}' Captive\ State\ \(2019\)\ Rupert\ Wyatt.mkv
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/mnt/bellatrix/downloads/test/Captive State (2019) Rupert Wyatt.mkv]
[MOVE] from [/mnt/bellatrix/downloads/test/Captive State (2019) Rupert Wyatt.mkv] to [/mnt/bellatrix/downloads/test/Captive State (2019).mkv]
Processed 1 files
$ vim xattr.groovy
$ filebot -script ./xattr.groovy
Captive State (2019) Rupert Wyatt.mkv
class java.lang.String
Done ヾ(@⌒ー⌒@)ノ
after testing I noticed I was running a very outdated version of the FUSE driver and upgrading it seems to have solved, apologies for the mistake.

Re: Can renamed file be 'un-renamed' ?

Posted: 30 May 2019, 16:52
by rednoah
I suppose if reading xattr doesn't work internally and then returns nothing, then FileBot will think there's nothing, and try to set it. Less well-tested filesystem implementations typically don't support xattr well. Similar things have come up before with certain SMB server implementations.