Python--音频文件分类代码
发布日期:2021-07-01 04:21:10 浏览次数:2 分类:技术文章

本文共 845 字,大约阅读时间需要 2 分钟。

上代码:

import osfrom shutil import copy2SOURCE = "c:\\source\\"DEST = "c:\\dest\\"# Iterate recursively through all files and folders under the source directoryfor path, dirs, files in os.walk(SOURCE):    # For each directory iterate over the files    for f in files:        # Grab the first letter of the filename        starting_letter = f[0].upper()        # Construct the full path of the current source file        source_path = os.path.join(path, f)        # Construct the destination path using the first letter of the        # filename as the folder        dest_path = os.path.join(DEST, starting_letter)        # Create the destination folder if it doesn't exist        if not os.path.isdir(dest_path):            os.makedirs(dest_path)        # Copy the file to the destination path + starting_letter        copy2(source_path, dest_path)

转载地址:https://mtyjkh.blog.csdn.net/article/details/79872310 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Python3--baby网的数据爬取
下一篇:Python爬虫之图片爬取

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月17日 17时16分40秒