Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import os
- import time
- import subprocess
- from datetime import datetime, timedelta
- path = '/opt/data/'
- rem_date = datetime.now() - timedelta(days=1)
- for subdir, dirs, files in os.walk(path):
- files.sort()
- for file in files :
- filetime = datetime.fromtimestamp(os.path.getctime(subdir + '/' + file))
- if filetime > rem_date and ( str(file).endswith('.wav') or str(file).endswith('.ogg')):
- file_name = os.path.splitext(file)[0]
- if str(file).endswith('.ogg') :
- outfile_name_audio = subdir + '/' + file_name
- else:
- outfile_name_audio = subdir + '/' + file_name + ".mp3"
- fullpath = subdir + '/' + file
- print "#####################"
- print "Start Time: " + datetime.now().strftime("%Y-%m-%d %H:%M")
- print "Original File : " + file
- print "New File : " +file_name
- cmd_audio = 'ffmpeg -i %s -ab 64k -y %s' % (fullpath, outfile_name_audio)
- subprocess.call([cmd_audio, "-y"], shell=True)
- print "Removing file: " + file
- os.remove(fullpath)
- print "Stop Time: " + datetime.now().strftime("%Y-%m-%d %H:%M")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement