Python creates a specific type file of the same file name in bulk

Source: Internet
Author: User

See a lot of batch create files and file batch format conversion code, feel kill Chicken Yan with Sledgehammer, wrote a few lines of lightweight to give you reference:

In the Out_dir directory, you bulk create files that differ from the In_dir directory with the filename but suffix.

In_dir = "d:\\data\\state_310000\\"
Out_dir = "d:\\data\\state_310000\\output\\"
Files = Os.listdir (In_dir)

For filename in Files:
Filename_split = Filename.split ('. '). Pop (0)
Print Out_dir+filename_split
If not os.path.exists (Out_dir):
Os.mkdir (Out_dir)
writer = open (Out_dir+filename_split, ' W ')
Writer.close ()

[Remark]: 1. File suffix can be arbitrarily censored 2. Content processing is not covered here

Success will

Create

Python creates a specific type file of the same file name in bulk

Related Article

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.