[PYTHON] Convert wma to mp3 on Mac

iTunes couldn't read .wma files

After investigating, I found that I could download an app called Switch and convert it.

However, the free portion had the disadvantage that only 5 cases could be converted at a time.

So, I made a program myself, so that memo.

procedure

  1. Install brew, install python I need brew. You also need python.
  2. Install ffmpeg
brew install ffmpeg
  1. Create conversion program
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import os
import fnmatch
from subprocess import call

matches = []
for root, dirnames, filenames in os.walk('./'):
    for filename in fnmatch.filter(filenames,'*.wma'):
        matches.append(os.path.join(os.path.abspath(root), filename))

for match in matches:
    message = "convert {0} to {1}".format(match, match.replace('.wma', '.mp3'))
    before = match.decode('utf-8')
    after = before.replace('.wma', '.mp3')
    print message
    if os.path.exists(after):
        print 'This file is already converted.'
    else:
        call(u'ffmpeg -i "{0}" "{1}"'.format(before, after), shell=True)
  1. Run

Be ready to run

chmod +x wma2mp3.py
mv wma2mp3.py /usr/bin/

Execute the following command in the directory containing the file you want to convert

wma2mp3.py

Recommended Posts

Convert wma to mp3 on Mac
Update python on Mac to 3.7-> 3.8
How to install mysql-connector-python on mac
Steps to install matplotlib on Mac
How to install OpenCV on Mac
Steps to install python3 on mac
Update Python on Mac from 2 to 3
How to install drobertadams / toggl-cli on Mac
I want to use Linux on mac
How to erase Python 2.x on Mac.
Convert to HSV
python on mac
Convert mp4 to mp3 with ffmpeg (thumbnail embedded version)
Preparing to run ImageMagick + im4java on Mac OS
Convert XLSX to CSV on the command line
Install Tensorflow on Mac
Install pyenv on mac
Convert 202003 to 2020-03 with pandas
Convert kanji to kana
Pyenv + virtualenv on Mac
Steps to install the latest Python on your Mac
Convert jupyter to py
Install Ansible on Mac
Very easy to install SciPy on Mac OS X
Preferences to generate animated GIFs from Python on Mac
Install Python on Mac
Install Python 3 on Mac
Convert keras-yolo3 to onnx
numba installation on mac
Convert dict to array
I want to AWS Lambda with Python on Mac!
Run OpenMVG on Mac
Convert json to excel
Install Python 3.4 on Mac
Install Caffe on Mac
Install mecab on mac
Install mecab-python on Mac
Try deepdream on Mac
Use pyOCR to convert the description on the card into text
How to convert Youtube to mp3 and download it super-safely [Python]
What to do if `pip install matplotlib` fails on Mac
Connect to centos6 on virtualbox with ssh connection from Mac
How to install Theano on Mac OS X with homebrew
Convert pixiv to mp4 and download from pixiv using python's pixivpy
Convert hexadecimal string to binary
[python] Convert date to string
Convert numpy int64 to python int
[Python] Convert list to Pandas [Pandas]
Notes on installing dlib on mac
Pyramid + mongodb environment on Mac
Convert HTML to text file
Install pygame on python3.4 on mac
Install module on Anaconda (Mac)
Install OpenPose on mac (Catalina)
How to register on pypi
Install numba on your Mac
Handling of python on mac
Install pandas 0.14 on python3.4 [on Mac]
Launch local server on mac
Convert Scratch project to Python
[Python] Convert Shift_JIS to UTF-8