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: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154:
| program ID3Changer;
{$APPTYPE CONSOLE}
uses SysUtils, Classes, FileCtrl, System, Dialogs;
type ID3Struct = record Signature: array[0..2] of Char; Title, Artist, Album: array[0..29] of Char; Year: array[0..3] of Char; Comment: array[0..29] of Char; Genre: Byte; end; const ID3Genre: array[0..125] of string = ( 'Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge', 'Hip-Hop', 'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B', 'Rap', 'Reggae', 'Rock', 'Techno', 'Industrial', 'Alternative', 'Ska', 'Death Metal', 'Pranks', 'Soundtrack', 'Euro-Techno', 'Ambient', 'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance', 'Classical', 'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel', 'Noise', 'AlternRock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative', 'Instrumental Pop', 'Instrumental Rock', 'Ethnic', 'Gothic', 'Darkwave', 'Techno-Industrial', 'Electronic', 'Pop-Folk', 'Eurodance', 'Dream', 'Southern Rock', 'Comedy', 'Cult', 'Gangsta', 'Top 40', 'Christian Rap', 'Pop/Funk', 'Jungle', 'Native American', 'Cabaret', 'New Wave', 'Psychadelic', 'Rave', 'Showtunes', 'Trailer', 'Lo-Fi', 'Tribal', 'Acid Punk', 'Acid Jazz', 'Polka', 'Retro', 'Musical', 'Rock & Roll', 'Hard Rock', 'Folk', 'Folk-Rock', 'National Folk', 'Swing', 'Fast Fusion', 'Bebob', 'Latin', 'Revival', 'Celtic', 'Bluegrass', 'Avantgarde', 'Gothic Rock', 'Progressive Rock', 'Psychedelic Rock', 'Symphonic Rock', 'Slow Rock', 'Big Band', 'Chorus', 'Easy Listening', 'Acoustic', 'Humour', 'Speech', 'Chanson', 'Opera', 'Chamber Music', 'Sonata', 'Symphony', 'Booty Bass', 'Primus', 'Porn Groove', 'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba', 'Folklore', 'Ballad', 'Power Ballad', 'Rhythmic Soul', 'Freestyle', 'Duet', 'Punk Rock', 'Drum Solo', 'Acapella', 'Euro-House', 'Dance Hall' );
procedure ListFileDir(Path: string; FileList: TStrings); var SR: TSearchRec; begin if FindFirst(IncludeTrailingBackSlash(Path) + '*.mp3', faAnyFile, SR) = 0 then begin repeat if (SR.Attr <> faDirectory) then begin FileList.Add(IncludeTrailingBackSlash(Path)+SR.Name); end; until FindNext(SR) <> 0; FindClose(SR); end; end;
function ReadID3Tag(sFileName:String):ID3Struct; var fMP3: file of Byte; Tag: ID3Struct; begin try AssignFile(fMP3, sFileName); Reset(fMP3); try Seek(fMP3, FileSize(fMP3) - 128); BlockRead(fMP3, Tag, SizeOf(Tag)) finally
end;
finally CloseFile(fMP3) end;
if tag.Signature<>'TAG' then begin
result:=tag; end else begin
end; result:=tag; end;
function StringProper (const sIn : string) : string; var i : integer; begin Result:=LowerCase(sIn); if Result='' then exit;
Result[1]:= UpCase(Result[1]); for i:= 2 to length(Result) do begin if Result[i - 1] = ' ' then begin Result[i]:= Upcase(Result[i]); end; end; end;
var sDir: String; fList: TStrings; i: integer; aSize: integer; curTag: ID3Struct; newTitle: String;
begin fList := TStringList.Create; if SelectDirectory('Please Select', 'C:\', sDir) then
begin ListFileDir(sDir, fList); try aSize := fList.Count; for i := 0 to aSize -1 do begin
curTag := ReadID3Tag(fList[i]);
if (curTag.Artist <> '') and (curTag.Title <> '') then begin newTitle := curTag.Artist + ' - ' + curTag.Title; newTitle := Trim(newTitle); newTitle := StringReplace(newTitle, '"', '', [rfReplaceAll]); newTitle := StringProper(newTitle); if (fList[i] <> sDir + '\' + newTitle + '.mp3') then begin WriteLn('Old title: ' + #09 + fList[i]); WriteLn('New title: ' + #09 + sDir + '\' + newTitle + '.mp3' + #10); RenameFile(fList[i], sDir + '\' + newTitle + '.mp3'); end; end; end; finally fList.Free; end; end; while true do begin end; end. |