Python--音频文件分类代码
发布日期:2021-07-01 04:21:10
浏览次数:3
分类:技术文章
本文共 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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年04月08日 04时01分55秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
UNIX环境变量--IPC之管道通信
2019-05-02
C++虚继承【详解】
2019-05-02
tinyhttpd源码学习1
2019-05-02
Plus One
2019-05-02
Linux内核完全剖析0.12(一)
2019-05-02
Sum Root to Leaf Numbers
2019-05-02
Pascal's Triangle
2019-05-02
ffmpeg提取音频存为PCM
2019-05-02
我也学android(1)搭个环境
2019-05-02
Reverse Linked List II
2019-05-02
最长递增子序列
2019-05-02
题目1511:从尾到头打印链表
2019-05-02
Web Bench 源码学习1
2019-05-02
Search Insert Position
2019-05-02
Length of Last Word
2019-05-02
QuickSort快速排序
2019-05-02
hdu2052
2019-05-02
ubuntu小技巧
2019-05-02
c语言细读之static auto
2019-05-02
ffmpeg开发中的问题(九)
2019-05-02