#1 2021-07-10 02:57

loungebob
Member
Registered: 2015-09-29
Posts: 45

Add Meta TAG to Folder name

I want to go from this:

Alejandro Escovedo - The Boxing Mirror

to this:

Alejandro Escovedo [2003] The Boxing Mirror

I thought I try this pascal script but it throws an error type mismatch at line 14.

const
  MASK = '*.flac';
  TAG = 'FLAC_Year';

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 := FileName + CalculateMetaTag(MasterFile, TAG);
  end;
end.

I assumed the script pulls the year tag from one (presumably the first) of the flac files and adds it at the end of the folder name. I'd then used rearrange to get the folder naming order I wanted.

All folder names are structured like the origin sample at the beginning and contain flac files and a jpg file. If it's easier, the Album Artist and the Album Name could be pulled from the flac meta data too but since all folders are almost completely formatted the way I want except for the [YEAR] part, I assume injecting just the year into the folder name is a simpler task...

Offline

#2 2021-07-10 09:20

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Add Meta TAG to Folder name

No time right now, only an hint:

See
https://www.den4b.com/wiki/ReNamer:Pasc … Management

WideScanDirForFiles(const Dir: WideString; var Files: TWideStringArray; const Recursive, IncludeHidden, IncludeSystem: Boolean; const Mask: WideString);


"Dir" and "Files" are variables.
"Dir" to provide the folder to work on
and "Files" as array to contain the resulting files.
But "Files" have to be declared first at the top, like your MasterFile, but as TWideStringArray.



Examples:
https://www.den4b.com/forum/viewtopic.p … 761#p11761

var
  ContainedFiles: TWideStringArray;

or there
https://www.den4b.com/forum/viewtopic.p … 451#p11451



.


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2021-07-10 13:34

loungebob
Member
Registered: 2015-09-29
Posts: 45

Re: Add Meta TAG to Folder name

I speak, write, understand and read 5 languages. Fluently. This is NOT one of them. I looked at it now for 20mins and got a headache.

I'll wait for when you got time. Or someone else.

I made it pretty though, look:

const
  FileMask = '*.flac';
  TAG = 'FLAC_Year';

var
  MasterFile: WideString;

function FindMasterFile(const Folder: WideString): WideString;
var
  Files: TWideStringArray;
begin
  Result := '';
  SetLength(Files, 0);
  WideScanDirForFiles(Folder, Files, False, False, False, FileMask);
  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.

I nuked the TStringsArray for TWideStringArray, changed MASK to FileMask and killed a line break. That's as far as I'll come. I read through the links and

Stefan wrote:

Examples:
https://www.den4b.com/forum/viewtopic.p … 761#p11761

var
  ContainedFiles: TWideStringArray;

this was even done for me lol. I guess you want me to define "Folder" since the "Files" and "FileMask" variables are already defined? Where, how and why? Nevermind I'll wait.

Offline

#4 2021-07-10 13:37

loungebob
Member
Registered: 2015-09-29
Posts: 45

Re: Add Meta TAG to Folder name

And yes, I realize that if I would read through it more thoroughly and played with example code I would eventually get there. But I'm also old enough to realize where energy and effort expenditure on my part is absolutely futile.

Offline

Board footer

Powered by FluxBB