Last active
October 22, 2018 22:43
-
-
Save fhfaa/740465abd2f5a204d457 to your computer and use it in GitHub Desktop.
ReNamer script: Name folders "$artist - $year - $album" according to ID3 the tags of the first contained *.MP3 (http://www.den4b.com/?x=products&product=renamer), ALSO rename "Artist - Album" to "Artist - Year - Album"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const | |
MASK = '*.mp3'; | |
var | |
MasterFile: WideString; | |
function FindMasterFile(const Folder: WideString): WideString; | |
var | |
Files: TStringsArray; | |
begin | |
Result := ''; | |
SetLength(Files, 0); | |
WideScanDirForFiles(Folder, Files, | |
False, False, False, MASK); | |
if Length(Files) > 0 then | |
Result := Files[0]; | |
end; | |
begin | |
if WideDirectoryExists(FilePath) then | |
begin | |
MasterFile := FindMasterFile(FilePath); | |
if MasterFile <> '' then | |
FileName := CalculateMetaTag(MasterFile, 'ID3_Artist') | |
+ ' - ' + CalculateMetaTag(MasterFile, 'ID3_Year') | |
+ ' - ' + CalculateMetaTag(MasterFile, 'ID3_Album'); | |
end; | |
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const | |
MASK = '*.mp3'; | |
TAG = 'ID3_Year'; | |
var | |
MasterFile: WideString; | |
YearString: WideString; | |
DashPos: Integer; | |
function FindMasterFile(const Folder: WideString): WideString; | |
var | |
Files: TStringsArray; | |
begin | |
Result := ''; | |
SetLength(Files, 0); | |
WideScanDirForFiles(Folder, Files, | |
False, False, False, MASK); | |
if Length(Files) > 0 then | |
Result := Files[0]; | |
end; | |
begin | |
if WideDirectoryExists(FilePath) then | |
begin | |
MasterFile := FindMasterFile(FilePath); | |
if MasterFile <> '' then | |
begin | |
YearString := CalculateMetaTag(MasterFile, TAG); | |
if YearString <> '' then | |
if YearString <> ' ' then | |
begin | |
DashPos := WidePos(' - ', FileName); | |
FileName := WideCopy(FileName, 1, DashPos - 1) + | |
' - ' + | |
YearString + | |
WideCopy(FileName, DashPos, WideLength(FileName) - DashPos + 1); | |
end; | |
end; | |
end; | |
end. | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment