2021年3月28日星期日

Rename subtitles with movie names from movie_name list to subtitles_list without regex

Rename subtitles with movie names from movie_name list to subtitles_list

import os    os.chdir("C:/Users/PC/Desktop/movies")    movies = []  for movie in os.listdir():      movie_name,ext = os.path.splitext(movie)      movies.append(movie_name)      print(movie_name)    subs = []  for sub in os.listdir("C:/Users/PC/Desktop/subs"):      sub_name, ext = os.path.splitext(sub)      subs.append(sub_name)      print(sub_name)        for movie,sub in zip(movies,subs):      os.rename(sub,movie+".srt")  

.........THE ERROR IS SHOWN AS GIVEN BELOW...............

movie_1  movie_2  movie_3  movie_4  A  B  C  D  Traceback (most recent call last):    File "C:\Users\PC\Desktop\ABCD.PY", line 19, in <module>      os.rename(sub,movie+".srt")  FileNotFoundError: [WinError 2] The system cannot find the file specified: 'A' -> 'movie_1.srt'  

How to tackle this error? Thank you.

https://stackoverflow.com/questions/66742367/rename-subtitles-with-movie-names-from-movie-name-list-to-subtitles-list-without March 22, 2021 at 04:15PM

没有评论:

发表评论