#1 2010-11-22 14:16

iycgtptyarvg
Member
Registered: 2009-07-30
Posts: 24

Number of files in directory

I have the task of renaming a huge amount of directories with the amount of files in them.

Before:
"My dir" which has 123 files inside it.
"My other dir" which has 321 files inside it.
"My empty dir" which has 0 files inside it.

After:
"My dir 123"
"My other dir 321"
"My empty dir 0"

How do I do this?

Disclaimer:
Although I'm a software engineer and could write an app for this myself, I was hoping to save a lot of time by having Renamer do this.

Offline

#2 2010-11-22 14:26

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Number of files in directory

http://www.den4b.com/forum/viewtopic.php?pid=4494#p4494
Take a look here to the post #4.

In your case the mask would be just "*".

Some more info about the scan function in this page:
http://www.den4b.com/wiki/ReNamer:Pasca … :Functions


If this software has helped you, consider getting your pro version. :)

Offline

#3 2010-11-22 16:14

iycgtptyarvg
Member
Registered: 2009-07-30
Posts: 24

Re: Number of files in directory

Ah! That's great. I didn't realize you could do that.

It worked very well indeed. Thank you very much.

Here is the script:

var
  Files: TStringsArray;

begin
  SetLength(Files, 0);
  WideScanDirForFiles(FilePath, Files, True, True, True, '*');
  FileName := FileName + ' ' + IntToStr(length(Files));
end.

Edit:
Good heavens! I just checked Pascal_Script:Functions and saw a lot more was possible!
I have always had a bit of difficulty using Renamer, but with these functions I (as a developer) can much more easily do what I want to do.

Thank you, thank you, thank you!

Last edited by iycgtptyarvg (2010-11-23 09:53)

Offline

#4 2010-11-23 09:58

iycgtptyarvg
Member
Registered: 2009-07-30
Posts: 24

Re: Number of files in directory

One last question:
Can I do something to change the filter settings? For most of my renaming I use only files, but this script obviously only uses folders. Is there a way to set that mode automatically in a rule?

Offline

#5 2010-11-23 14:19

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Number of files in directory

You can save the preset with that rule, and on the save dialog you'll have a check box where you can specify to save the filter with it.


If this software has helped you, consider getting your pro version. :)

Offline

#6 2010-11-23 15:36

iycgtptyarvg
Member
Registered: 2009-07-30
Posts: 24

Re: Number of files in directory

That worked! I feel my life is now complete and all is right with the Universe. ;-)

Offline

Board footer

Powered by FluxBB