Python moves files in multiple sub-files into a folder

Source: Internet
Author: User

1 ImportOS2 ImportOs.path3 ImportShutil4 5 defListdir (dirtemp):6     ifNone = =dirtemp:7         return8     GlobalNameList9     if  notos.path.exists (dirtemp):Ten         Print "file or directory isn ' t exist" One         return A  -     ifOs.path.isfile (dirtemp): -         ifDirtemp.find ('. wmv') >0:namelist.append (dirtemp) the         return -  -Resultlist =Os.listdir (dirtemp) -  +      forFileordirinchresultlist: -Listdir (Dirtemp +"/"+Fileordir) +  A     returnNameList at  -  -Path = R'F:\java Web Learning'. Decode ('Utf-8') -NameList = [] -list=listdir (path) -  forIteminchlist: inShutil.move (item, PATH)

When a folder in the file is not directly in a folder, but in a subfolder of the folder, it is used in this code to move all the files to the specified folder.

Python moves files in multiple sub-files into a folder

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.