Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

[JS] How to get folder count?

Contributor ,
Apr 03, 2016 Apr 03, 2016

Hi.

I want to get a number of folders for a specific directory.

var folderCount = Folder("C:/test/file/").getFiles( ? );    // Is this what values need?

alert(folderCount.length);

If this method is wrong, please tell me the other way.

Thanks

TOPICS
Scripting
5.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Apr 03, 2016 Apr 03, 2016

Hi,

Get all files from folder and then check whether it is a file or folder. Try this one

var myFileList = Folder("D:/Test").getFiles();

var folderCount = GetFoldersCount(myFileList) ;

$.writeln(folderCount);

function GetFoldersCount(fileList)

{     

    var folderCount = 0;

    for (var i = 0; i < fileList.length; i++)

    { 

        var myFile = myFileList

        if (myFile instanceof Folder) 

            folderCount++;

    } 

    return folderCount

Translate
Participant ,
Apr 03, 2016 Apr 03, 2016
LATEST

Hi,

Get all files from folder and then check whether it is a file or folder. Try this one

var myFileList = Folder("D:/Test").getFiles();

var folderCount = GetFoldersCount(myFileList) ;

$.writeln(folderCount);

function GetFoldersCount(fileList)

{     

    var folderCount = 0;

    for (var i = 0; i < fileList.length; i++)

    { 

        var myFile = myFileList

        if (myFile instanceof Folder) 

            folderCount++;

    } 

    return folderCount

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines