As we all know, in the Internet to download a variety of resources, especially TV dramas, each set name will be regularly added some website advertising information, brought us a lot of inconvenience, or is obsessive-compulsive.
Because of self-study for a period of time Python, long night ~ ~ Bored in trying to write a few lines of code to quickly rename.
Novice think poorly, hope you advice, especially each execution according to the situation also need a variety of changes
Import os# before executing, modify the file path of Path = '/users/yjx/desktop/lie to Me/lie to me S3 ' # Traverse folder for file name in Os.listdir (path): #根据自己的需要 File name modification The #mac system will have hidden. Ds_store the properties file, so first judge if file! = '. Ds_store ': #根据不同的名字, perform different logic processing names = File.split ('. ') New_name = names[4] + names[-1] #将文件名重命名为新的名字os. Rename (Os.path.join (path,file), Os.path.join (Path,new_name))
This article remember that programming adds a bit of fun to my life.
Python-Renaming a TV show