Help with creating a simple script to rename directories

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
User avatar
deadman36g
Posts: 9
Joined: 28 Jan 2014, 02:56

Help with creating a simple script to rename directories

Post by deadman36g »

I have currently been using the following command with the filebot gui to rename my movies for me

{n} ({y})/{fn}

Here is an example of what this does

my movie is movie.2014.x264.mkv, it will create the directory 'Movie (2014)' and put my movie file inside this directory.

I am wanting to automate this process.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with creating a simple script to rename directories

Post by rednoah »

:idea: Please read the FAQ and How to Request Help.
User avatar
deadman36g
Posts: 9
Joined: 28 Jan 2014, 02:56

Re: Help with creating a simple script to rename directories

Post by deadman36g »

I have been trying but no luck, could you please make me this script?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with creating a simple script to rename directories

Post by rednoah »

Command:

Code: Select all

filebot -rename -r . --output "D:/output" --format "TV/{n}/{s}/{n} - {s00e00} - {t}" -non-strict --action copy --db thetvdb
Output:

Code: Select all

Rename episodes using [TheTVDB]
Auto-detected query: [True Blood, Blood]
Fetching episode data for [True Blood]
Fetching episode data for [A Drop of True Blood]
Fetching episode data for [Blood+]
Fetching episode data for [Blood-C]
Fetching episode data for [Blood Lad]
Fetching episode data for [Bad Blood]
Fetching episode data for [Hot Blood]
[COPY] Rename [D:\workspace\testdata\AMC-TEST\True.Blood.S05E01.BDRip.XviD-REWARD.avi] to [D:\output\TV\True Blood\5\True Blood - S05E01 - Turn! Turn! Turn!.avi]
Processed 1 files
So where is the issue? Cause this stuff documented in details - with examples - on the website, and with many many more examples here in the forums. If you can't be bothered to RTFM I do expect a kind donation for doing it for you. :mrgreen:
:idea: Please read the FAQ and How to Request Help.
User avatar
deadman36g
Posts: 9
Joined: 28 Jan 2014, 02:56

Re: Help with creating a simple script to rename directories

Post by deadman36g »

I am sorry I wasn't specific enough

I want this script to leave my filenames as they are. I just want the directory created and the files moved to the directory.

i.e.

movie/new/filebot2014.x264.DTS.mkv

would become

movie/new/Filebot (2014)/filebot2014.x264.DTS.mkv
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with creating a simple script to rename directories

Post by rednoah »

Change format:

Code: Select all

--format "TV/{n}/{fn}"
This exact use-case is give as an example:
http://www.filebot.net/forums/viewtopic.php?f=5&t=2

Please read the manual. It's all there.
:idea: Please read the FAQ and How to Request Help.
User avatar
deadman36g
Posts: 9
Joined: 28 Jan 2014, 02:56

Re: Help with creating a simple script to rename directories

Post by deadman36g »

I did RTFM but still have trouble

I have made a few modifications to the code you gave me so that it is now

Code: Select all

filebot -rename -r . --format "{n} ({y})/{fn}" -non-strict --action move --db imdb
What does the . between -r and --format represent?

I would like a script that I can autorun with windows that will watch a folder for any changes and run the above code when there is a change.

And for your help on this, and for making such an awesome (and free) app a donation will certainly be coming your way.
User avatar
bonelifer
Power User
Posts: 81
Joined: 23 Mar 2013, 18:27

Re: Help with creating a simple script to rename directories

Post by bonelifer »

The "-r" option tells filebot to handle folders recursively, the "." tells filebot to do it "from the current folder". So say the folder is "movie/new/" then it would tell it to start from "movie/new/". If it was ".." it would tell it to start from one folder below current folder ie "movie/".
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with creating a simple script to rename directories

Post by rednoah »

-rename "X:/path/to/files" (in your case it's probably best to specify an absolute path)
-r select all files in this folder and sub-folders
--format "expr" naming scheme => http://www.filebot.net/naming.html
--output "Y:/media" folder that will be used to resolve relative naming schemes
:idea: Please read the FAQ and How to Request Help.
User avatar
deadman36g
Posts: 9
Joined: 28 Jan 2014, 02:56

Re: Help with creating a simple script to rename directories

Post by deadman36g »

Thanks, didn't realize '.' was current folder

So, is it possible for a script to autorun on windows login that will moniter a folder for changes and run my command when there is one?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with creating a simple script to rename directories

Post by rednoah »

There's this for watching folders:
http://www.filebot.net/forums/viewtopic ... 4&t=5#p132

Though I'd recommend using AMC and set Windows Task Scheduler to call it in intervals:
http://www.filebot.net/forums/viewtopic.php?f=4&t=215
:idea: Please read the FAQ and How to Request Help.
User avatar
deadman36g
Posts: 9
Joined: 28 Jan 2014, 02:56

Re: Help with creating a simple script to rename directories

Post by deadman36g »

Ok, I went with the first one because I do not use utorrent and it is working as desired with this script

Code: Select all

filebot -script fn:watcher C:\Users\deadman36g\Downloads\MOVIES -rename -r . --format "{n} ({y})/{fn}" -non-strict --action move --db imdb 
No, I have a few more questions

1.) How can I keep this running in the background without keeping a cmd window open at all times

2.) I would still like a log kept even if the cmd window is closed, is this possible?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with creating a simple script to rename directories

Post by rednoah »

1. You can try chp though it might not work:
Alternatively you can create a hidden filebot process with this tool: http://www.commandline.co.uk/chp/
2. filebot -help

Code: Select all

--log-file path/to/log.txt             : Log file
:idea: Please read the FAQ and How to Request Help.
Post Reply