Difference between revisions of "ReNamer:Scripts:Using MasterFile"

From den4b Wiki
Jump to navigation Jump to search
(navigation)
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(3 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
== Tested ==
 
== Tested ==
  
* ReNamer 5.50
+
* ReNamer 5.74.4 Beta
  
 
== Code ==
 
== Code ==
Line 13: Line 13:
 
Author: Denis Kozlov. Date: 14 Sep 2008.
 
Author: Denis Kozlov. Date: 14 Sep 2008.
  
<source>
+
<syntaxhighlight lang="pascal">
 
const
 
const
 
   MASK = '*.mp3';
 
   MASK = '*.mp3';
Line 23: Line 23:
 
function FindMasterFile(const Folder: WideString): WideString;
 
function FindMasterFile(const Folder: WideString): WideString;
 
var
 
var
   Files: TStringsArray;
+
   Files: TWideStringArray;
 
begin  
 
begin  
 
   Result := '';
 
   Result := '';
Line 41: Line 41:
 
   end;
 
   end;
 
end.
 
end.
</source>
+
</syntaxhighlight>

Latest revision as of 15:03, 8 February 2017

This code will find a first file in the folder which matches MASK, and will append value of a TAG of that file to the folder's name.

For the folder "Artist - Title" and the mp3 file inside that folder with the Year tag set to "1993" the script will produce output "Artist - Title 1993".

Tested

  • ReNamer 5.74.4 Beta

Code

Author: Denis Kozlov. Date: 14 Sep 2008.

const
  MASK = '*.mp3';
  TAG = 'ID3_Year';

var
  MasterFile: WideString;

function FindMasterFile(const Folder: WideString): WideString;
var
  Files: TWideStringArray;
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 := FileName + ' ' + CalculateMetaTag(MasterFile, TAG);
  end;
end.