Skip to content

Instantly share code, notes, and snippets.

@shinespark
Created October 29, 2015 17:21
Show Gist options
  • Save shinespark/95717f0e5aef2e4ec024 to your computer and use it in GitHub Desktop.
Save shinespark/95717f0e5aef2e4ec024 to your computer and use it in GitHub Desktop.
m4a2m4r.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from os.path import abspath, basename, splitext
import os
import glob
files = glob.glob('./*.m4a')
os.system('mkdir ./cache')
for file in files:
print file
name, ext = splitext(basename(file))
name = name.replace(' ', '\\ ')
name = name.replace('\'', '\\\'')
name = name.replace('\!', '\\\!')
filename = name + ext
os.system('ffmpeg -i ~/Desktop/' + filename + ' -acodec copy ~/Desktop/cache/' + name + '.m4a' )
# print('ffmpeg -i ' + filename + ' -acodec copy ./cache/' + name + '.m4r' )
files = glob.glob('./cache/*.m4a')
for file in files:
name, ext = splitext(basename(file))
name = name.replace(' ', '\\ ')
name = name.replace('\'', '\\\'')
name = name.replace('\!', '\\\!')
filename = name + ext
# os.system('mv ' + filename + ' ' + name + '.m4r')
os.system('mv ~/Desktop/cache/' + filename + ' ~/Desktop/cache/' + name + '.m4r')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment