Commit 1ca52594 authored by Félix Michaud's avatar Félix Michaud
Browse files

cleaning

parent 1180ccf2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 26 18:22:10 2019
@author: felix
"""
import os
import fnmatch
def createFolder(directory):
if not os.path.exists(directory):
os.makedirs(directory)
return 0
def create_list(path, ext):
list_audios = []
for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, '*' + ext):
list_audios.append(os.path.join(root, filename))
return list_audios
def num_char(x):
return(x.rsplit("(", 1)[0].split("+", 1)[1])
path_audio = './audio/'
ext = '.wav'
audio_list = create_list(path_audio, ext)
audio_list.sort()
for ii in range(len(audio_list)):
classB = num_char(audio_list[ii])
createFolder(path_audio + classB)
os.rename(audio_list[ii], path_audio + classB +'/'+ audio_list[ii].rsplit('/', 1)[1])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment