Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marie Tahon
u-net4birds
Commits
1ca52594
Commit
1ca52594
authored
Aug 09, 2019
by
Félix Michaud
Browse files
cleaning
parent
1180ccf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
cleaning.py
0 → 100644
View file @
1ca52594
#!/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
])
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment