Get list of subfolders

Next
 From:  vector illustrator (QUARITEXA)
9640.1 
I need to get list of 'commands' subfolders.
I tried this:
code:
new ActiveXObject("Scripting.FileSystemObject").GetFolder(moi.filesystem.getCommandsDir()).SubFolders.count;

It returns right amount of subfolders. But I don't know how to get the list.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9640.2 In reply to 9640.1 
Hi Quaritexa, there is a moi.filesystem.getFiles() for getting a list of all files in a folder, but nothing currently for getting all directories. I will see about adding that in for the next v4 beta.

ActiveXObject is not supported on v4 anymore. There is an example here on how to iterate through the FileSystemObject Folders collection (which SubFolders returns) here: https://support.microsoft.com/en-us/help/229693/how-to-use-jscript-or-javascript-to-traverse-through-a-collection . I'm not sure if that uses something special from Microsoft's JScript script engine though. It may not work in MoI since starting with MoI v3 it uses the WebKit JavaScriptCore script engine instead of the Microsoft JScript script engine.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9640.3 In reply to 9640.1 
Hi Quaritexa, I've added a moi.filesystem.getDirs() method for the next v4 beta that will do this.

For v3 a method that you could try is doing something like a moi.filesystem.shellExecute( 'cmd.exe', '/C /Q dir c:\\ > c:\\scripts\\filename.txt' ) , that should run the dir command of the shell and output it to a file. Then you would need to parse the file.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  vector illustrator (QUARITEXA)
9640.4 In reply to 9640.3 
I tried
code:
var cd = moi.filesystem.getCommandsDir(); 
moi.filesystem.shellExecute('cmd.exe', '/c dir /a:d /b /o:n "' + cd + '" > "' + cd + 'dir.tmp"');

But it displays the shell window. How to suppress it?
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Phiro
9640.5 In reply to 9640.4 
In your command line the /q option is missing
Perhaps is it the problem
The /c option is use to close the Window but /q avoids the echo
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9640.6 In reply to 9640.4 
Hi Quaritexa,

re:
> But it displays the shell window. How to suppress it?

A couple of possibilities here:
https://superuser.com/questions/191149/how-to-execute-cmd-exe-silently

Maybe this one:
http://www.joeware.net/freetools/tools/quiet/

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  vector illustrator (QUARITEXA)
9640.7 In reply to 9640.6 
Thank you, Michael.

I chose this one:
code:
var pd = moi.filesystem.getProcessDir();
var cd = moi.filesystem.getCommandsDir(); 
moi.filesystem.shellExecute(pd + 'nircmd', 'exec hide cmd.exe /c dir /a:d /b /o:n '+ cd + '> '+ cd + 'dir.tmp');
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All