-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBack up songs.ahk
127 lines (110 loc) · 3.38 KB
/
Back up songs.ahk
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#NoEnv
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
#NoTrayIcon
#Include %A_ScriptDir%\tf.ahk
mode := 2
sort := true ;true = sort; anything else = doesn't
include_deemix_links := true ;true = include deemix links; anything else = doesn't
Music_collection_directory := "C:\My files\Music"
Loop, Files, *.txt
{
FileDelete, %A_LoopFileFullPath%
}
objShell := ComObjCreate("Shell.Application")
global objShell
mp3_tags =
filename =
if mode = 1
{
Loop, Files, %Music_collection_directory%\*.mp3, R
{
;Get all file names for trackid extraction later
filename = %filename%%A_LoopFileName%`n
;Get id3/mp3 tags
mp3_tags = % mp3_tags id3read_taaly(A_LoopFileName, A_LoopFileDir)"`n"
}
}
else if mode = 2
{
Loop, Files, %Music_collection_directory%\*.mp3, R
{
;Get all file names for trackid extraction later
filename = %filename%%A_LoopFileName%`n
;Get id3/mp3 tags
mp3_tags = % mp3_tags id3read_taa(A_LoopFileName, A_LoopFileDir)"`n"
}
}
else if mode = 3
{
Loop, Files, %Music_collection_directory%\*.mp3, R
{
;Get all file names for trackid extraction later
filename = %filename%%A_LoopFileName%`n
;Get id3/mp3 tags
mp3_tags = % mp3_tags id3read_aat(A_LoopFileName, A_LoopFileDir)"`n"
}
}
else if mode = 4
{
Loop, Files, %Music_collection_directory%\*.mp3, R
{
;Get all file names for trackid extraction later
filename = %filename%%A_LoopFileName%`n
;Get id3/mp3 tags
mp3_tags = % mp3_tags id3read_at(A_LoopFileName, A_LoopFileDir)"`n"
}
}
FileAppend, %mp3_tags%, Song info.txt
FileAppend, %filename%, Song file names.txt
TF_RemoveDuplicateLines("!Song info.txt",1,0,1,false)
TF_RemoveDuplicateLines("!Song file names.txt",1,0,1,false)
TF_RemoveBlankLines("!Song info.txt")
TF_RemoveBlankLines("!Song file names.txt")
;Trackids
TF_RegExReplace("!Song file names.txt",".+ - ","")
TF_RegExReplace("!Song file names.txt","m).mp3$","")
FileMove, Song file names.txt, Trackids.txt, 1
;Links
TF_InsertPrefix("Trackids.txt",1,0, "https://www.deezer.com/us/track/")
FileMove, Trackids_copy.txt, Links.txt, 1
;Include deemix links
if (include_deemix_links = true)
{
TF_InsertSuffix("!Song info.txt",1,0, " - ")
TF_ConCat("Song info.txt","Links.txt","Song info.txt")
}
;Total songs
Total_songs := TF_CountLines("Song info.txt")
FileAppend, %Total_songs%, Total songs.txt
;Describe mode
if (sort = true)
{
TF_Sort("!Song info.txt", "", 1, 0)
}
FileMove, Song info.txt, Song info (mode %mode%).txt
;Functions
id3read_taa(FileName,FileDir)
{
oDir := objShell.NameSpace(FileDir)
oMP3 := oDir.ParseName(FileName)
return oDir.GetDetailsOf(oMP3, 21) " - " oDir.GetDetailsOf(oMP3, 13) " - " oDir.GetDetailsOf(oMP3, 14)
}
id3read_aat(FileName,FileDir)
{
oDir := objShell.NameSpace(FileDir)
oMP3 := oDir.ParseName(FileName)
return oDir.GetDetailsOf(oMP3, 13) " - " oDir.GetDetailsOf(oMP3, 14) " - " oDir.GetDetailsOf(oMP3, 21)
}
id3read_taaly(FileName,FileDir)
{
oDir := objShell.NameSpace(FileDir)
oMP3 := oDir.ParseName(FileName)
return oDir.GetDetailsOf(oMP3, 21) " - " oDir.GetDetailsOf(oMP3, 13) " - " oDir.GetDetailsOf(oMP3, 14) " - " oDir.GetDetailsOf(oMP3, 27) " - " oDir.GetDetailsOf(oMP3, 15)
}
id3read_at(FileName,FileDir)
{
oDir := objShell.NameSpace(FileDir)
oMP3 := oDir.ParseName(FileName)
return oDir.GetDetailsOf(oMP3, 13) " - " oDir.GetDetailsOf(oMP3, 21)
}