Python Bulk Modify File name

Source: Internet
Author: User

1 ImportOS2 3 4 #1. Get the name of the folder you want to rename:5folder_name = input ("Please enter the folder you want to rename:")6 7 8 #2. Get all the file names in that folder:9File_names =Os.listdir (folder_name)Ten  One  A """ - # The first method of - Os.chdir (folder_name) # Enter the Folder_name folder the # 3. Rename the acquired name to: - For name in File_names: - print (name) - os.rename (Name, "[uninjured] [produced by]-" +name) + """ -  +  A #The second method of at  forNameinchFile_names: -Old_file_name ="./"+ folder_name +"/"+ Name#The name file in the Folder_name folder under the current path -New_file_name ="./"+ folder_name +"/"+"[Wang Jing Cooperation]"+ Name#The new name of the name file in the Folder_name folder under the current path -Os.rename (Old_file_name,new_file_name)

Python Bulk Modify File name

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.