[iTunes] Using CLI to rename every file in a folder using MediaInfo

All about user-defined episode / movie / file name format expressions
Post Reply
ajibarra
Posts: 1
Joined: 10 Jul 2020, 09:46

[iTunes] Using CLI to rename every file in a folder using MediaInfo

Post by ajibarra »

Hello,

I have a large media collection that was processed with iTunes some years ago. For some reason iTunes finds funny consolidating all episodes in a single folder. To make things better, the name format is something like "EPISODE_NUMBER EPISODE_TITLE" making a hard task to process these files with other tools.

After some time finding out why my files were renamed correctly in the UI and then when I tried to do the same in CLI it failed I was able to rename my files.

The key is that you need to use MediaInfo attributes in your format instead of using default ones like {n} and {s00e00}:

Code: Select all

filebot --db file -rename --format "{media.collection} {media.partID}" 
You have some other attributes that you can check in the UI. I recommend loading a file in "Edit format" -> "Change sample" so you can see available attributes.

Then if you want to process all files in a folder you can simply execute it inside a for loop:

Code: Select all

for i in *; do filebot --db file -rename --format "{media.collection} {media.partID}" "$i"; done
Remember this will only work if your media has the attributes set. You can confirm using mediainfo tool or any other.

Thanks to @rednoah for pointing me at this.
patpat22
Posts: 1
Joined: 30 Jul 2020, 11:13

Re: [iTunes] Using CLI to rename every file in a folder using MediaInfo

Post by patpat22 »

ajibarra wrote: 10 Jul 2020, 10:39 Hello,

I have a large media collection that was processed with iTunes some years ago. For some reason iTunes finds funny consolidating all episodes in a single folder. To make things better, the name format is something like "EPISODE_NUMBER EPISODE_TITLE" making a hard task to process these files with other tools.

After some time finding out why my files were renamed correctly in the UI and then when I tried to do the same in CLI it failed I was able to rename my files.

The key is that you need to use MediaInfo attributes in your format instead of using default ones like {n} and {s00e00}:

Code: Select all

filebot --db file -rename --format "{media.collection} {media.partID}" 
You have some other attributes that you can check in the UI. I recommend loading a file in "Edit format" -> "Change sample" so you can see available attributes.

Then if you want to process all files in a folder you can simply execute it inside a for loop:

Code: Select all

for i in *; do filebot --db file -rename --format "{media.collection} {media.partID}" "$i"; done
Remember this will only work if your media has the attributes set. You can confirm using mediainfo tool or any other.

Thanks to @rednoah for pointing me at this.
I quit using iTunes some time ago. But this post might help me somehow in the future. I appreciate it.
Post Reply