#1 2008-01-05 20:34

Spike
Member
Registered: 2008-01-05
Posts: 2

Meta tags from files to folders

It would be nice when renaming folders to be able to use meta tag info from the first file in the folder. For example I have mp3 folders in the format

Artist - Album

and wish to rename them

Artist - Album (year)

Offline

#2 2008-01-07 17:26

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Meta tags from files to folders

Good news for you - it is possible! smile

For the starters, you can have a look at the similar problem and solution here:
Same name for all files as an existing file in the folder

And then, here is the modified script from the topic above, to suite your needs (look below). 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.

const
  MASK = '*.mp3';
  TAG = 'ID3_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.

Offline

#3 2008-01-07 22:44

Spike
Member
Registered: 2008-01-05
Posts: 2

Re: Meta tags from files to folders

Ah thank you very much. Super program btw, puts others to shame smile

Offline

Board footer

Powered by FluxBB