-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathios_kuwoMusic_trans.py
79 lines (47 loc) · 1.47 KB
/
ios_kuwoMusic_trans.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# coding: utf-8
# In[118]:
__author__ = ''
import sqlite3
import os
conn=sqlite3.connect("//mnt2/无损音乐/0000/cloud.db")
import sys
reload(sys)
sys.setdefaultencoding('utf8')
# In[119]:
def GetNewFilename(filename):
try:
cu = conn.cursor()
cu.execute("select artist,title,album,file,format from musicResource where file='%s'"%filename)
r = cu.fetchone()
except IOError:
print "Error: 没有找到文件或读取文件失败"
else:
print "内容写入文件成功"
if r is not None:
artist,title,album,filename,format=r
newfilename2 = "%s-%s.%s"%(artist,title,format)
print(newfilename2)
newfilename2.replace("&","").replace(":","").replace(" ","").replace("/","")
print(newfilename2)
return newfilename2
def ConvertFiles(path):
if not os.path.exists(path):
exit()
pl = os.listdir(path)
print(pl)
for file in pl:
#如果不是目录就移动
#计算新文件名
print(file)
if os.path.isfile(os.path.join(path,file)) :
newfilename = GetNewFilename(file)
if newfilename is not None:
print(path)
print(os.path.join(path,file),"-->",os.path.join(path,newfilename))
os.rename(os.path.join(path,file),os.path.join(path,newfilename))
# In[120]:
ConvertFiles('//mnt2/无损音乐/0000/Music/')
conn.close()
# In[ ]:
# In[ ]:
# In[ ]: