#1 2024-04-22 20:31

jer24
Member
Registered: 2024-04-22
Posts: 3

Parent and grand parent folder names

How would I traverse subfolders to a current location and then use a piece of those folder names in the resulting file name?
The result would be-  MyMovie_s01E01, ....,MyMovie_s01E04,MyMovie_s02E01...

I'm not familiar with looping in pascal and dont see any functions that would loop through.

My folder structure:
Movie1
    folder_Season1_D1
        File01
        File02
        File03
    folder_Season1_D2
        File01
        File02
        File03
    folder_Season2_D2
        File01
        File02
        File03
    folder_Season2_D2
        File01
        File02
        File03

Offline

#2 2024-05-02 14:24

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

Re: Parent and grand parent folder names

You can use the ":File_FolderName:" meta tag to access the parent folder name, but there is no meta tag to access the grand parent folder name. However, you can access both via the Pascal Script rule.

The script below will prefix your files with both grand parent and parent folder names.

var
  ParentFolder, GrandParentFolder: WideString;
begin
  ParentFolder := WideExtractFileDir(FilePath);
  GrandParentFolder := WideExtractFileDir(ParentFolder);
  ParentFolder := WideExtractFileName(ParentFolder);
  GrandParentFolder := WideExtractFileName(GrandParentFolder);
  FileName := GrandParentFolder + '_' + ParentFolder + '_' + FileName;
end.

Offline

#3 2024-05-21 14:13

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

Re: Parent and grand parent folder names

In v7.5.0.3 Beta, a new meta tag was added to access the grandparent folder name.

Now you can use :File_FolderName: and :File_GrandparentFolderName: meta tags to access both parent and grandparent folder names, respectively, without having to resort to a script.

Offline

Board footer

Powered by FluxBB