728x90
반응형
https://www.tabnine.com/code/java/methods/org.jaudiotagger.audio.mp3.MP3File/save
@
https://hclee2575.tistory.com/539
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
|
package test;
import java.io.File;
import java.io.IOException;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.exceptions.CannotReadException;
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.audio.mp3.MP3File;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;
import org.jaudiotagger.tag.TagException;
import org.jaudiotagger.tag.id3.AbstractID3v2Tag;
public class test {
public static void main(String[] args) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException {
File dir = new File("Z:\\HDD1\\Music\\Music 02 Cloud House\\02 EDM House 01 Melody");
//디렉토리 안 파일의 패턴
//2008 - Veracocha - Carte Blanche (Ilan Bluestone Remix)
File files[] = dir.listFiles();
int cnt = 1;
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.isDirectory()) {
// System.out.println(file.getPath());
} else {
System.out.println("["+cnt+"]"+file);
String path ="";
String fileName ="";
path = file.getParentFile().toString();
fileName = file.getName();
String[] tempEmail = fileName.split(" - ");
String email1 = null;
String email2 = null;
String email3 = null;
String[] email4 = null;
String email5 = null;
if (tempEmail != null && tempEmail.length >= 2) {
email1 = tempEmail[0];
email2 = tempEmail[1];
email3 = tempEmail[2];
email4 = email3.split(".mp3");
email5 = email4[0];
}
/*
System.out.println(email3);//파일명
System.out.println(email4);//파일명
*/
// System.out.println(fileName);//파일명
// System.out.println(email1);//연도
// System.out.println(email2);//가수
// System.out.println(email5);//제목
MP3File mp3 = (MP3File) AudioFileIO.read(file);
AbstractID3v2Tag tag2 = mp3.getID3v2Tag();
Tag tag = mp3.getTag();
String title = tag.getFirst(FieldKey.TITLE);
String artist = tag.getFirst(FieldKey.ARTIST);
String album = tag.getFirst(FieldKey.ALBUM);
String year = tag.getFirst(FieldKey.YEAR);
String genre = tag.getFirst(FieldKey.GENRE);
// System.out.println("Tag : " + tag2);
// System.out.println("Song Name : " + title); //제목
// System.out.println("Artist : " + artist); //아티스트
// System.out.println("Album : " + album); //앨범
// System.out.println("Year : " + year); //연도
// System.out.println("Genre : " + genre); //장르
tag.setField(FieldKey.TITLE, fileName);
tag.setField(FieldKey.ARTIST, email2);
tag.setField(FieldKey.ALBUM, email2);
tag.setField(FieldKey.YEAR, email1);
// System.out.println("year : " + tag.getFirst(FieldKey.YEAR));
mp3.setTag(tag);
mp3.save();
cnt++;
}
}
}
}
|
cs |
@
728x90
반응형