Python-Renaming a TV show

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.