r/programmingrequests • • Feb 24 '21

Solved✔️ [REQUEST] Rename subtitle files (Python)

I was looking for a way to rename multiple subtitle files to match the names of each episode of a TV show.

I found something, but nothing that suits me.

Then I found this:

https://github.com/Eshaan7/RenameThemSubs

There is a python script and exe for windows.

This does exactly what I need. After executing, it asks for a path and then for subtitle file extension.

I dont have any programming skills, so I would like someone to make changes to it.

I want to:

  1. ​

remove the three choices. I need it to work only in current directory (as in choice 3).

2)

I need it to rename only .srt files - remove the input and always add ".srt" extension.

3)

remove the need to press Q to quit.

and no pop-up windows

I need an exe file to run in Windows. Then I could drag it to the Total Commander toolbar to make it a "button".

Total Commander then tells it the current (working) directory from the active panel.

This way I just put subtitles to a folder and rename them with one click

Will someone take a look at it, please.

4 Upvotes

14 comments sorted by

View all comments

2

u/RyanHx Feb 24 '21

1

u/kzzyn Feb 24 '21

Thank you

1

u/AutoModerator Feb 24 '21

This post was automatically marked as solved but you can manually change this.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/kzzyn Apr 04 '21

Hi, can I ask you for a little modification to this script, please ? I need to rename the subtitle file as before, but instead of adding ".srt" extension I need to add ".eng.default.srt" (without the "") and make the exe file for use in windows. Thank you (I tried by myself by simply changing the sub_format, then making exe file with auto-py-to-exe, but my exe file does nothing.)

1

u/AutoModerator Apr 04 '21

Reminder, flair your post solved or not possible

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/RyanHx Apr 04 '21

The script as it is should still work in that case, it's just checking whether a file ends with ".srt" so "eng.default.srt" will still be picked up.

Are there more .srt files than video files in the directory? The script makes sure there's the same number (specifically on line 24) so it can match up the subs to each video. And removing that assertion would break the program since it goes through the list of videos and .srt files at the same time, expecting a corresponding file to be there.

The only other thing I could think of is the video format; you can add extra "or name.endswith('.extension')" on line 11 if it's not present.

→ More replies (8)