GetDirList??

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

GetDirList??

Post by pgriffin » Wed Feb 08, 2006 2:56 pm

GetDirList would be such a "natural" for MSched, I actually thought it was a current command. I have written a few lines to use CMD to write the results of a dir *. to a file, but is there a more 'elegant' way to do this?

GetDirList>c:\SomeFolder,MyList
Sep>MyList,;,DIR

yadda yadda.....is what I am looking for, but is there anything for now better than using CMD and some DOS commands?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Feb 08, 2006 3:05 pm

My apologies for not "searching first" before posting a question. I found some VB here on the forum which will probably do what I need.

I still would like to use my "imaginary" command...GetDirList

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Feb 08, 2006 5:49 pm

Does GetFileList not do the job:

GetFileList>c:\somedir\*.*,list

What would GetDirList do that is different?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Wed Feb 08, 2006 6:15 pm

When I use your code I do not get a list of any of the directories. Only files.

the VB example you put on the forum will work nicely.

GetDirList would ignore files within a given directory. I've tried GetFileList>c:\somefolder\*.,DIR but with no luck.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Feb 08, 2006 6:24 pm

Right, sorry, I didn't understand what you wanted it to achieve. I do now.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Feb 09, 2006 7:59 am

Hi SkunkWorks,

I agree, GetDirList does seem like a natural for Macro Scheduler, great idea. In the meantime, you mentioned some VB code was posted that will do this. I found the following helpful post...

How to build a directory list
http://www.mjtnet.com/usergroup/viewtopic.php?t=2310

Was that the post you were talking about?

Thanks

P.S. Marcus, has GetDirList made it onto the official wishlist or should something be posted about this on the Enhancement Suggestion forum?
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Feb 09, 2006 8:29 am

It's on the list.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Thu Feb 09, 2006 2:15 pm

jpuziano,

I couldn't find the same post, so, at the risk of duplicating a post....here it the code to find all folders within a folder.

/VB example for recursive dir listing and files contained in the directories.
//set your path here ...
Let>path=C:\MainMenu\

VBSTART
Function GetFolderList(folderspec)
Dim fso, f, f1, fc, s, sf
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
s = s & f1.name & ";"
sf = GetFolderList(folderspec & "\" & f1.name)
if sf "" then
s = s & f1.name & "\" & sf & ";"
end if
Next
If s "" then
s = Mid(s,1,Len(s)-1)
End If
GetFolderList = s
End Function
VBEND

//list files in path
GetFileList>%path%*.*,filelist
Separate>filelist,;,files
If>files_count>0
Let>f-cntr=0
Repeat>f-cntr
Let>f-cntr=f-cntr+1
MessageModal>files_%f-cntr%
Until>f-cntr,files_count
Endif

//Enumerate files in all subfolders in path
VBEVAL>GetFolderList("%path%"),folderList
Separate>folderList,;,folders

Let>d-cntr=0
Repeat>d-cntr
Let>d-cntr=d-cntr+1
Let>subfolder=folders_%d-cntr%
Let>subfolderpath=%path%%subfolder%
MessageModal>Now for files in %subfolderpath%
GetFileList>%subfolderpath%\*.*,filelist
Separate>filelist,;,files
If>files_count>0
Let>i=0
Repeat>i
Let>i=i+1
Let>thefile=files_%i%
MessageModal>thefile
Until>i,files_count
Endif
Until>d-cntr,folders_count



...I changed the path name and the names of the counters in the Repeat command, other than that it is the same as the original post.....

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Feb 09, 2006 8:40 pm

Thanks SkunkWorks :D
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

1medic
Newbie
Posts: 7
Joined: Sat Apr 22, 2006 11:25 am

Post by 1medic » Mon May 01, 2006 11:15 am

I was searching for something similar today in order to write an ftp script.

This dos command also supplies a list of directories below the current path:

dir /a:d /b /s

This gives a list of directories using their full paths.

Luke

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts