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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
做的很好,不错不错
[***.243.131.199]2024年04月17日 17时16分40秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Android--W/System.err: java.net.UnknownServiceException: CLEARTEXT communication to 10.114.35.103
2019-05-02
谈Objective-C Block的实现
2019-05-02
iOS中block实现的探究
2019-05-02
facebook开源动画pop
2019-05-02
GCD 深入理解(一)
2019-05-02
将数据库select出来的数据转化为与相应databean对应的字典
2019-05-02
优化UITableView滚动性能
2019-05-02
如何把sqlserver中的列转换成行,行转换成列,显示。
2019-05-02
Xcode 5 单元测试(一)使用XCTest进行单元测试
2019-05-02
Xcode 5 单元测试(二)OCMock和GHUnit
2019-05-02
用alter关键字为Table增加新字段(sqlite)
2019-05-02
GCD 深入理解(二)
2019-05-02
UIView动画
2019-05-02
NSURLConnection的使用
2019-05-02
Objective C类方法load和initialize的区别
2019-05-02