Rename folders without touching original files

Any questions? Need some help?
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Rename folders without touching original files

Post by andreyy »

Hello! I'm looking for the following solution:
1. I need my movies to be downloaded to a specific folders. They can have names with no strict standards.
2. I need a tool that will parse contents of this folder and then create a new structure of folders at a new location. Each folder will represent a movie and will be named to follow some standard. It will contains a link to the movie at original location.

So then I could give this new folders to my scraper (that requires that each movie will be placed in its own folder) and it will understand how to process the links to original files.
And it allows me to seed torrents at its original locations.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

GUI? Switch to symlink rename action. CLI? Use --action symlink. The output structure is defined by the format.
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

As far as I understand, there is no chance to use symlinks on Java SE 6?
I can't install Java 7 on Synology :(
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

Nope. With Java 6 you're screwed. The only thing you can do is --action copy.

Or if you really need to you can pass in a custom rename function and run the ln -s command (on Linux anyway). There's examples in the forums but its advanced usage.
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

thanks for the answer! could you please send me a link regarding this custom functions?
i'm trying to apply amc script, so I hope I could combine custom renaming with it.
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

This one shows you everything you need:
http://www.filebot.net/forums/viewtopic ... =280#p1750

Just add a groovy closure as action parameter and just execute the ln program with the given from/to parameters.
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

Excuse me for noob question.
I tried to find how to combine a custom rename script with

Code: Select all

-script fn:amc
but haven't got this.

As for sym link, I should use this snippet:

Code: Select all

rename(
   file: args.getFiles(),
   action: { from, to ->
      execute('ln -s ', from, to)
   }
)
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

And one additional question or problem.
I found that AMC script makes 2 same subfolders for the blueray rip.
E.g:
/Lawless (2012)/Lawless(2012)/BDMV/*
instead of just:
/Lawless (2012)/BDMV/*
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

Consider this:
/Lawless (2012)/Lawless(2012).avi => folder + file
/Lawless (2012)/Lawless(2012).iso => folder + file
/Lawless (2012)/Lawless(2012) => folder + disk folder (where disk folder is treated as single entity, like a file)

Maybe you have CD1, CD2, etc disk folders?

This is default. If you want something different just define it in the format, e.g.

Code: Select all

{file.isDirectory() ? "FOLDER" : "FILE"}
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

rednoah, thank you for your detailed answer.

Let me give example
/torrent/Gone.in.Sixty.Seconds.2000.BDRemux.1080p.CEE/Gone in Sixty Seconds (2000).mkv becomes /Movies/Gone in Sixty Seconds (2000)/Gone in Sixty Seconds (2000).mkv
(it's OK)

/torrent/Closer.2004.1080p.BD-Remux/BDMV/ becomes /Movies/Closer (2004)/Closer (2004)/BDMV/<other files inside>
(it's not OK) - this is a result of having BDMV folder that come with torrent.

1. I can't understand how to change the logic of AMC script and how can I even edit it.
2. Can you give an answer to this topic to: http://www.filebot.net/forums/viewtopic ... 4389#p4386

My CLI:
filebot -rename -r "/video/" -script fn:amc --output "/Video" --conflict override -non-strict --action test

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

Re: Rename folders without touching original files

Post by rednoah »

1.
Remove -rename -r as it has no effect, or in case of -r intended side-effects (the script handles folder structures itself).

2.
Read the docs, look --def movieFormat, read the naming scheme docs if you don't quite get it.

2.1.
As for testing more complicated formats prototype with the Format Editor in the FileBot GUI. Once you grasp how the format engine works you'll see this is all Hello World level programming.

3.
The snipped I gave you is a fully functional standalone script. Just shows how you can pass in your own rename action closure. Now you need to grab amc.groovy, make changes to the rename(...) calls, and execute your local script (not remote fn:amc).
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

It looks I've got the real point - I have to edit local version amc.groovy.
And it seems that f.isDisk() is not detecting Bluray folder structure correctly. This results to my problem mentioned above (Closer (2004)/Closer (2004)/).

Probably I could fix it by adding something to this line:
if (f.isDirectory() && !f.isDisk())
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

1.
It is renaming the folder as a whole, and not the files inside, right? => f.isDisk() works.

2.
You want a movie-folder/movie-file structure. This is what you get when the movie-file itself is a disk folder.

e.g.
Closer (2004)/Closer (2004) Disk 1/BDMV/**
Closer (2004)/Closer (2004) Disk 2/BDMV/**

You'd fix it exactly as I showed you. If target {file} is in fact a folder, not a file. Then this folder must be a disk folder and is treated as if it was a single file. But you can do your own logic.

To make this perfectly copy-and-paste-ably clear:

Code: Select all

{file.isFile() ? "$n ($y)/" : "./"}{n} ({y}){" CD$pi"}
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

I'll try to make my question clear. I would like to modify amc.groovy so that:
1. It will rename using ln -s
2. Make Closer (2004)/BDMV/** instead of Closer (2004)/Closer (2004) Disk 1/BDMV/**.
Is it possible to do that? Can I hire somebody who will help?
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

Yes, Actually I've already given you all the answers, you just need to put it together, i.e. copy-paste-programming.

Though you can "hire" me by sending over a donation to the project. ;)
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

I've just sent you a donation. Could you please do me a favor with the script? :)
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

Your Custom Rename Action & Format AMC script:
http://pastebin.com/caKW5h3F

Dev on Windows so the ln -s call fails here... it'll work in you run it on linux though. ;)

Code: Select all

Parameter: ut_dir = D:\testdata\AMC-TEST
Parameter: ut_title = AMC-TEST
Input: D:\testdata\AMC-TEST\Avatar.2009.dvd
Input: D:\testdata\AMC-TEST\Pawn.2013.Custom.DKsubs.NTSC.DVDR-SUBLiME\sublime-pawn.iso
Avatar.2009.dvd [series: null, movie: Avatar (2009)]
sublime-pawn.iso [series: null, movie: Pawn (2013)]
Group: [tvs:null, mov:Avatar (2009), anime:null] => [Avatar.2009.dvd]
Group: [tvs:null, mov:Pawn (2013), anime:null] => [sublime-pawn.iso]
Rename movies using [TheMovieDB]
Auto-detect movie from context: [D:\testdata\AMC-TEST\Avatar.2009.dvd]
[CLOSURE] Rename [D:\testdata\AMC-TEST\Avatar.2009.dvd] to [D:\output\Movies\.\Avatar (2009)]
'ln' is not recognized as an internal or external command,
operable program or batch file.
Processed 1 files
Rename movies using [TheMovieDB]
Auto-detect movie from context: [D:\testdata\AMC-TEST\Pawn.2013.Custom.DKsubs.NTSC.DVDR-SUBLiME\sublime-pawn.iso]
[CLOSURE] Rename [D:\testdata\AMC-TEST\Pawn.2013.Custom.DKsubs.NTSC.DVDR-SUBLiME\sublime-pawn.iso] to [D:\output\Movies\Pawn (2013)\Pawn (2013).iso]
'ln' is not recognized as an internal or external command,
operable program or batch file.
Processed 1 files
Done ヾ(@⌒ー⌒@)ノ
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

Thanks a lot for your help, it works!!
Now one additional question - is it possible to deal with mismatched titles or titles that wasn't detected in CLI version?
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

1.
Not really. Especially mismatches, if it knew there's a mismatch it there wouldn't be a mismatch.

2.
Not really, by default. Though you could come up with all kinds of custom logic. Start by defining "undetected files". Just media files? Exclude samples? What to do with it. Retain folder structure. What part of the folder structure.
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

Regarding undetected files.
I have cases like these:
- SecHand Lions/BDMV/*
- Holostjak.2009.x264.BDRip(1080p).mkv

These files and folders haven't been processed because of the bad naming of source. I would like them to be linked (ln -s) to the same location as a detected (processed) movies. Or at a special subfolder (like /Movies/Unknown/).
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

Sorry, these things are not in TheMovieDB. Kinda mafan to wrap something around the whole amc to keep track of files that should get renamed but weren't.

Probably can be done by cross-checking input set with rename history and then looping over the remainder and do something with it.
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

Is it possible to have some kind of buffer that will contain unprocessed files and folders.
This buffer will be just pushed to the destination folder as is.

The additional problem is that symbol links are not working on NFS file system.
ohh...
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

Yeah, it's just code, anything is possible. But AMC is not designed as wizard that'll step you through all your media. It should be as simple as possible.

If you first process all the good files, shouldn't it be really easy to process all the remainder in a second step?

As long as it's the same filesystem you can hardlink. That should work right?
:idea: Please read the FAQ and How to Request Help.
andreyy
Posts: 19
Joined: 09 Apr 2013, 15:42

Re: Rename folders without touching original files

Post by andreyy »

Rednoah, could I gently ask you to help me with the moving the rest of the files to the new location! I will very appreciate your help!:)
I hope that hardlinks will work!
User avatar
rednoah
The Source
Posts: 22986
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename folders without touching original files

Post by rednoah »

Not home right now, but this should get almost, if not completely, what you want.

Just add piece of code at the end of amc (and fix syntax errors as i'm just typing this down from back of my head :P)

Code: Select all

input.each{ f ->
   if ( !getRenameMap().containsKey(f) ) {
      println "[REMAINING FILE] $f"
      f.copyTo(new File("/path/to/remainder"))
   }
}
:idea: Please read the FAQ and How to Request Help.
Post Reply