A couple of things about this script.
You can run this over and over again without closing the main program and the times should be accurate for each run for each process. However, the VB window will continuously append to the displayed directories list until you actually close the script and restart it. I don't know Visual Basic so I don't know how to prevent the list from growing other than to close the program and start it again.
If you browse to a folder that will be the starting point for the list, you must select a file in that folder, The dialog browse fuction will not let you select a directory, you can only select a file. The script will strip the filename off before it runs, you do not need to do it manually. If you type in a path and directory name, you do not need to type in a file name.
Hope someone finds this useful,
Dick
Code: Select all
Let>title=Path Selection
Dialog>Dialog1
Caption=%title%
Width=285
Height=212
Top=50
Left=CENTER
Label=Directory to process,32,88
Label= ,32,1
CheckBox=msCheckBox1,Get Directories using DOS,32,32,153,False
CheckBox=msCheckBox2,Get Directories using VB,32,56,145,False
Edit=msEdit1,32,104,121,
Button=Process,32,152,75,25,3
Button=Cancel,168,152,75,25,2
Button=Browse,168,104,75,25,4
FileBrowse=Browse,msEdit1
Default=Process
EndDialog>Dialog1
Show>dialog1
GWP>%title%,psX,psY
Let>DOSx=%psX%-310
Let>DOSy=%psY%+25
Let>VBx=%psX%+295
Let>VBy=%psY%+25
Dialog>Dialog2
Caption=DOS List
Width=300
Height=400
Top=%DOSy%
Left=%DOSx%
Label=DOS Directory List,15,5
EndDialog>Dialog2
Dialog>Dialog3
Caption=VB List
Width=300
Height=400
Top=%VBy%
Left=%VBx%
Label=VB Directory List,15,5
EndDialog>Dialog3
Let>cleartest=0
Let>null=
Label>start
GetDialogAction>Dialog1,r
Wait>0.01
If>r=2,exit
If>r=3,Process
If>r=4,Pick
If>{(%Dialog1.msEdit1%<null>Dialog1.mslabel1=%SPACE%
ResetDialogAction>Dialog1
Let>cleartest=0
EndIF
goto>start
Label>Process
If>Dialog1.msEdit1=
Let>Dialog1.mslabel1=No Directory Selected
ResetDialogAction>Dialog1
Let>cleartest=1
Goto>start
EndIF
IfDirExists>%Dialog1.msEdit1%
Goto>dirpassed
Else
separate>%Dialog1.msEdit1%,\,testval
Let>tk=0
Let>testdir=
sub>testval_count,1
Repeat>tk
add>tk,1
Let>value=testval_%tk%
Concat>testdir,value
Concat>testdir,\
Until>tk,testval_count
IfDirExists>%testdir%
Let>Dialog1.msEdit1=%testdir%
Goto>dirpassed
EndIf
Let>Dialog1.mslabel1=%Dialog1.msEdit1%%CRLF%Is not a valid directory name
Let>Dialog1.msEdit1=
ResetDialogAction>Dialog1
Let>cleartest=1
Goto>start
EndIF
Label>dirpassed
LEN>%Dialog1.msEdit1%,chars
Midstr>%Dialog1.msEdit1%,chars,1,lastchar
If>lastchar=\
//DoNothing
Else
concat>Dialog1.msEdit1,\
EndIf
If>Dialog1.msCheckBox1=True
Let>path=%Dialog1.msEdit1%
GetTime>starttime
GoSub>DOS
EndIF
If>Dialog1.msCheckBox2=True
Let>path=%Dialog1.msEdit1%
GetTime>starttime
GoSub>VB
EndIF
goto>start
SRT>DOS
Let>RP_WAIT=1
Let>RP_WINDOWMODE=2
Run>cmd /c dir "%path%*.*" /s /ad /b > %TEMP_DIR%~directorylist~.txt
ReadFile>%TEMP_DIR%~directorylist~.txt,list
GetTime>endtime
Show>dialog2
Let>Dialog2.mslabel0=DOS Directory List%CRLF%Ran From %starttime% To %endtime%%CRLF%%CRLF% Generating Directory count, Please Wait...%CRLF%%CRLF%%list%
ResetDialogAction>Dialog1
ResetDialogAction>Dialog2
Separate>list,%CRLF%,Cval
sub>cval_count,1
Let>Dialog2.mslabel0=DOS Directory List%CRLF%Ran From %starttime% To %endtime%%CRLF%%CRLF%%Cval_count% Directories under %Dialog1.msEdit1%%CRLF%%CRLF%%list%
ResetDialogAction>Dialog2
Let>list=
END>DOS
SRT>VB
VBSTART
Dim fs, outList
Sub GetAllSubFolders(foldername)
On Error Resume Next
Dim f, fc
Set f = fs.GetFolder(foldername)
Set fc = f.SubFolders
For Each f in fc
outList = outList & f.Path & ";"
GetAllSubFolders foldername & "\" & f.name
Next
End Sub
Function DoGetAllSubs(foldername)
Set fs = CreateObject("Scripting.FileSystemObject")
GetAllSubFolders foldername
DoGetAllSubs = Mid(outList,1,Len(outList)-1)
End Function
VBEND
VBEval>DoGetAllSubs("%path%"),list
GetTime>endtime
RPL>list,;,%CRLF%,list
Show>dialog3
Let>Dialog3.mslabel0=VB Directory List%CRLF%Ran From %starttime% To %endtime%%CRLF%%CRLF% Generating Directory count, Please Wait...%CRLF%%CRLF%%list%
ResetDialogAction>Dialog1
ResetDialogAction>Dialog3
Separate>list,%CRLF%,Cval
Show>dialog3
Let>Dialog3.mslabel0=VB Directory List%CRLF%Ran From %starttime% To %endtime%%CRLF%%CRLF%%Cval_count% Directories under %Dialog1.msEdit1%%CRLF%%CRLF%%list%
ResetDialogAction>Dialog3
Let>list=
END>VB
Label>exit