Skip to main content
Inspiring
September 26, 2022
Question

Finding number of files in folder issue.

  • September 26, 2022
  • 2 replies
  • 334 views

Hi there,

I just want to check number of files in folder.

 

//Actual code to get number of files in folder in cmd.

dir /b /s /a-d  "E:\\myFolder\\*.jpg\" | find /c /v ""

 

//modified in jsx below

var count=system.callSystem("cmd /c \"dir /b /s /a-d \"E:\\myFolder\\*.jpg\" | find /c /v \"\" \"");

alert(count);
 or
var count=system.callSystem("cmd /c \"dir /b /s /a-d \"E:\\myFolder\\*.jpg\" | find /c /v \"\" > \"E:\\testRun\\res.txt\"\"");
 
None works.
 
Someone help.
This topic has been closed for replies.

2 replies

Mylenium
Legend
September 26, 2022

It's probably the numerous nested quotation marks throwing things off. Have you tried to URI encode/ decode your string? Otherwise I'd go with Mathias suggestion, which also would be advisable in terms of cross-platform compatibility when needed.

 

Mylenium

Mathias Moehl
Community Expert
Community Expert
September 26, 2022

Maybe it is easier to use the Folder.getFiles() function than performing a system call?

Not that the function returns a list of files and folders, so you need to iterate over the list and only count the ones that are acually files.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Inspiring
September 26, 2022
Folder.getFiles().length is too slow compared to dos command, that's why i
wanted to do this way where i have 80K image sequence in each folder.

--


Please consider the environment before
printing this mail



The
information contained in this e-mail is private & confidential and may also
be legally privileged. If you are not the intended recipient of this mail,
please notify us, preferably by e-mail; and do not read, copy or disclose
the
contents of this message to anyone. Whilst we have taken reasonable
precautions
to ensure that any attachment to this e-mail has been swept for
viruses, e-mail
communications cannot be guaranteed to be secure or error
free, as information
can be corrupted, intercepted, lost or contain
viruses. We do not accept
liability for such matter or their consequences