this post was submitted on 14 Jun 2023
6 points (87.5% liked)

Open Source

30511 readers
415 users here now

All about open source! Feel free to ask questions, and share news, and interesting stuff!

Useful Links

Rules

Related Communities

Community icon from opensource.org, but we are not affiliated with them.

founded 5 years ago
MODERATORS
 

I have 291 episodes named tv.show.01.mp4 to tv.show.291.mp4 and i want rename them to be named like Tv Show Episode S01E01.mp4. I use Linux so please suggest only FOSS compatible programs

top 25 comments
sorted by: hot top controversial new old
[–] [email protected] 5 points 1 year ago (1 children)

I use KRename for renaming multiple files.

[–] higante 1 points 1 year ago

I second krename. Works flawlesly for me.

[–] synapse1278 4 points 1 year ago

You can take a look at "sonarr", it's made for managing your tv-shows and it can automatic rename and organize your files, with customizable naming schem.

[–] [email protected] 3 points 1 year ago* (last edited 1 year ago)

you can try rename: https://www.man7.org/linux/man-pages/man1/rename.1.html

or
rename 's/expression/replacement/' filename

select range of episodes per season then add season number (eg S01) in replacement string.

then restart numbering for next set of episodes (eg 01 to 12) and add S02. and so on. more tedious than the gui Rename method but doable.

[–] [email protected] 2 points 1 year ago (2 children)

Please don't use spaces in your *nix filenames, that is just bad. To answer your question, use a bash script. Chatgpt can probably even make it for you if you don't know how to write it.

[–] [email protected] 1 points 1 year ago

I know but jellyfin suggest to use that type of nomenclature so...

[–] fubo 1 points 1 year ago

If you want to use spaces in filenames, it's a good reason to write in something other than shell; although modern shells can be made to work with spaces in filenames safely, it's still fiddly.

[–] [email protected] 2 points 1 year ago

This can be done natively in Thunar if you happen to use XFCE.

[–] [email protected] 2 points 1 year ago

There must be a million utilities to do this (try searching "linux mass rename"), including ones that allow you to rename media files based on their metadata... each works in different ways, so you'll have to look yourself for one that fits you (personally, I like the ones who open a text editor with the file names and you just edit them).

If you use KDE (DK about other environments) and only need a progressive counter, the simplest way is just select the files in dolphin, hit F2 and enter a pattern like "Tv Show Episode S01E##.mp4".

(of course you can also write a script to rename the files, but I guess you wouldn't have asked if you were prepared to do so)

[–] [email protected] 2 points 1 year ago (2 children)

krenamer can do this. It just is a regex front end. You could do it with a shell script too.

[–] [email protected] 1 points 1 year ago

That's what i started using :)

[–] INeedMana 1 points 1 year ago* (last edited 1 year ago)

I might have messed something up but I think you should be able to take it from here:

function split_season() { 
  S=$((($1-1)/$2))
  E=$(($1-$S*$2))
  printf "S%02dE%02d" $(($S+1)) $E  
}

EPISODES_PER_SEASON=15

for f in tv.show.*.mp4; do
  NUMBER=`echo $f|sed 's/[^[:digit:]]*\([[:digit:]]*\).mp4/\1/'`
  #maybe put echo at the beginning of the next line to test before moving?
  mv "$f" "Tv Show $(split_season $NUMBER $EPISODES_PER_SEASON).mp4"
done
[–] [email protected] 1 points 1 year ago

There are various GUI tools (eg., gprename, krename) but I prefer qmv, a CLI tool from the renameutils package. It opens filenames into a vim (or your default editor) session, with which you can use global regex search/replace commands to rename files.

[–] [email protected] 1 points 1 year ago (1 children)

how can you identify season from the file name?

[–] fubo 2 points 1 year ago (1 children)

One approach: Look up what TV show has 291 episodes; land on this Wikipedia page which gives you the season lengths.

[–] [email protected] 1 points 1 year ago

good and fun idea ;)

[–] [email protected] 1 points 1 year ago

Would the tvnamer utility help?

[–] [email protected] 1 points 1 year ago (1 children)

Why not just do this with a for loop in the terminal? I don’t think you need to over complicate it by downloading another program.

[–] [email protected] 3 points 1 year ago

If I was able to do that i would not have asked here lol

[–] [email protected] 1 points 1 year ago
[–] [email protected] 1 points 1 year ago

or if you are comfortable with command line and some replacement shenanigans, there is always mmv

[–] [email protected] 1 points 1 year ago

If the names don't have any break for seasons, or the name of the episode, I think it's going to take a couple steps. Renaming is easy, but you're adding info that's not in the name. I can only suggest trying something like tvnamer, or search for a similar project.

[–] [email protected] 1 points 1 year ago

Dolphin has that ability built in. If you use it, highlight all of the episodes and press f2. Pretty self explanatory from there.

[–] [email protected] 1 points 1 year ago

I use nomino for this purpose.

load more comments
view more: next ›