#1 2020-10-06 01:10

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

Number of folder contents added to folder name

couldn't find anything on this. is there a function that counts the number of folder contents (maybe even filtered by file type) and adds that number to the folder name?

Offline

#2 2020-10-06 14:08

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

Re: Number of folder contents added to folder name

This can be done with the Pascal Script rule.

The script below will insert into the folder name the number of files contained within the folder. You can adjust the FileMask and Recursive constants to suit your needs. The number is currently appended to the end of the folder name, but this can also be customized in code.

const
  FileMask = '*';
  Recursive = False;
var
  ContainedFiles: TWideStringArray;
begin
  if WideDirectoryExists(FilePath) then
  begin
    SetLength(ContainedFiles, 0);
    WideScanDirForFiles(FilePath, ContainedFiles, Recursive, False, False, FileMask);
    FileName := FileName + ' ' + IntToStr(Length(ContainedFiles));
  end;
end.

Reference:
https://www.den4b.com/wiki/ReNamer:Pascal_Script

Offline

#3 2020-10-06 19:21

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

Re: Number of folder contents added to folder name

thanks mate! that works fabbo. and I'm kinda proud I even got to modify it so it now prints "_[XXFILES]"
and that's really good for someone so logic challenged lol
if I also wanted to contents of folders to be matched to a database (like TVDB) and verified I probably should go another route/tool, should I? or is this something I could figure out using pascal script as well?

Offline

#4 2020-10-07 20:21

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

Re: Number of folder contents added to folder name

loungebob wrote:

if I also wanted to contents of folders to be matched to a database (like TVDB) and verified I probably should go another route/tool, should I? or is this something I could figure out using pascal script as well?

We could probably hack something together in Pascal Script, but it does sound like a task for a more specialized tool, i.e. developed specifically for that purpose.

Offline

Board footer

Powered by FluxBB