Page 1 of 1

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

Posted: 10 Jul 2020, 10:39
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.

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

Posted: 30 Jul 2020, 11:37
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.

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

Posted: 17 Aug 2020, 17:09
by latigocount
great!