-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaming.py
43 lines (24 loc) · 789 Bytes
/
naming.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import re
# delete extra chars
W = os.getcwd()
soundfiles = os.listdir(W)
if '.DS_Store' in soundfiles: soundfiles.remove('.DS_Store')
for item in soundfiles: os.rename(item, item[:-11]+'.csv')
# substitute space for underscore
W = os.getcwd()
soundfiles = os.listdir(W)
if '.DS_Store' in soundfiles: soundfiles.remove('.DS_Store')
for item in soundfiles:
if '-' in item:
os.rename(item, re.sub('-', '_', item))
# prepend folder name to file
W = os.getcwd()
folders = os.listdir(W)
if '.DS_Store' in folders: folders.remove('.DS_Store')
for folder in folders:
songs = os.listdir(folder)
if '.DS_Store' in songs:
songs.remove('.DS_Store')
for song in songs:
os.rename(folder+'/'+song, folder+'__'+song)