经常批量处理文件,这里有个python的模板,保存一下

这个例子是把目录里面所有子目录的mp3文件放慢0.85倍并保存到./processed/目录下面。

#coding=utf-8
import sys,os ,shutil
import struct
import glob
import time
import subprocess def slow(file_name,to_file):
command='ffmpeg -i {} -af atempo=0.85 {} '.format(file_name,to_file)
print(command)
os.system(command) def process_file(file_name,dest_node):
if not file_name.endswith('.mp3'):
return;
slow(file_name,dest_node) def process_dir(folder):
for sub_node in glob.glob ( folder+'/*' ):
dest_node=sub_node.replace(node,"../processed/")
if os.path.isdir(sub_node):
if not os.path.isdir(dest_node):
os.mkdir(dest_node)
process_dir(sub_node)
else:
process_file(sub_node,dest_node) node=sys.argv[1]
if os.path.isdir(node):
process_dir(node)
for pcm_file in glob.glob ( node+'/*' ):
process_file(pcm_file)
if os.path.isfile(node):
with open(node, 'r') as file_to_read:
for line in file_to_read.readlines():
process_file(line)

最新文章

  1. Python:list用法
  2. PHP_php.ini_说明详解
  3. POJ3177 & 求边双联通分量
  4. instancetype、id、NSObject的联系和区别
  5. My way to Python - Day05 - 面向对象
  6. javascript innerHTML、outerHTML、innerText、outerText的区别
  7. http head
  8. ionic 图片轮播问题
  9. WebRTC VoiceEngine使用简单Demo
  10. 2017-3-22 HTML 表单 、框架
  11. 字符函数 php
  12. C++后台实践:古老的CGI与Web开发
  13. GO语言系列(五)- 结构体和接口
  14. 【Python全栈-后端开发】Django进阶2-Form表单
  15. jmeter基本使用
  16. 单细胞数据高级分析之初步降维和聚类 | Dimensionality reduction | Clustering
  17. gulp 添加版本号 解决浏览器缓存问题
  18. 使用android模拟器开发程序
  19. Python: dict setdault函数与collections.defaultdict()的区别
  20. JavaScript学习(二)——深入学习js对象的原型与继承

热门文章

  1. Systemverilog for design 笔记(四)
  2. rarlinux安装和使用
  3. ABC155F - Perils in Parallel
  4. Python 基础之序列化模块pickle与json
  5. 设计模式课程 设计模式精讲 9-2 原型模式coding
  6. C++11并发编程1------并发介绍
  7. Codeforces 1196D2 RGB Substring (Hard version) 题解
  8. 报错google.protobuf.text_format.ParseError: 166:8 : Message type "object_detection.protos.RandomHorizontalFlip" has no field named "i".解决方法
  9. mysql设置timpstamp的默认值为 '0000-00-00 00:00:00' 时报错
  10. Android 自定义PopWindow完整代码