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

Finding number of files in folder issue.

Participant ,
Sep 26, 2022 Sep 26, 2022

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.
TOPICS
Scripting
273
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
Community Expert ,
Sep 26, 2022 Sep 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
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
Participant ,
Sep 26, 2022 Sep 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
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
Participant ,
Sep 26, 2022 Sep 26, 2022
LATEST

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.

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
LEGEND ,
Sep 26, 2022 Sep 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

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