I need get a list of folder names within a folder much like GetFileList will get a list of files within a folder.
Any ideas? Thanks.
Need GetDirList or GetFolderList
Moderators: JRL, Dorian (MJT support)
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
DIR *. will provide a list of folders.
should give a file with a list of the folders in c:\myfolders folder. Results will be in the file folders.txt in the myfolders folder.Run Program>command /c dir c:\myfolders\*. > c:\myfolders\folders.txt
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Need GetFolderList
I found a solution but you need to use VBScript. Make sure that the script is placed before any code that uses it.
DLeger
VBSTART
Function GetFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
s = s & f1.name
s = s & ";"
Next
GetFolderList = s
End Function
VBEND
let>myDir=C:\Whatever
VBEVAL>GetFolderList("%myDir%"),folderList
Separate>folderList,;,folders
let>count=folders_count-1
MessageModal>Num Folders: %count%
Let>k=0
Repeat>k
Let>k=k+1
MessageModal>folders_%k%
Until>k,count
DLeger
VBSTART
Function GetFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
s = s & f1.name
s = s & ";"
Next
GetFolderList = s
End Function
VBEND
let>myDir=C:\Whatever
VBEVAL>GetFolderList("%myDir%"),folderList
Separate>folderList,;,folders
let>count=folders_count-1
MessageModal>Num Folders: %count%
Let>k=0
Repeat>k
Let>k=k+1
MessageModal>folders_%k%
Until>k,count
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
Hi!
I too need a GetDirList function.
I have tried both suggested solutions, but they dont help very much.
The first gives a lot of text that makes it hard to separate the Dir names.
And the second dont work at all for me. I get a VB compilation error.
Any other ideas or solutions on how to get the names of the directorys?
Thanks!
Tomas
I too need a GetDirList function.
I have tried both suggested solutions, but they dont help very much.
The first gives a lot of text that makes it hard to separate the Dir names.
And the second dont work at all for me. I get a VB compilation error.
Any other ideas or solutions on how to get the names of the directorys?
Thanks!
Tomas
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Let's go back to:The first gives a lot of text that makes it hard to separate the Dir names.
I was just trying to give you the basic tool to get the information. More steps need to be taken to make it more legible.Posted: Thu Feb 12, 2004 4:34 pm
Post subject: DIR *. will provide a list of folders.
Run Program>command /c dir c:\myfolders\*. > c:\myfolders\folders.txt
should give a file with a list of the folders in c:\myfolders folder. Results will be in the file folders.txt in the myfolders folder.
From the folders.txt file, make a loop to read the file, use MidStr to capture the first 20 characters of the lines starting with line 8. Send results to a file. If line does not include then end process. Open the file and you have your list of directories.
Start the total script with an Input> prompt for the beginning directory, and you will have a generic Directory List tool. Input has a built in Browse button and the ability to have a default.
The power of Macro Scheduler is that this can be a one-keystroke solution,
but you will have to write some code to make it happen.
Rough outline of script:
Input>
Run Program> dir *. \s > folders.txt
Start Loop
Read lines in folders.txt
Skip First 7 lines
Read first 20 characters and append to a file: DirList.txt
Go to next line and repeat loop until line does not inlcude
End loop
Open DirList.txt
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
-
- Pro Scripter
- Posts: 149
- Joined: Tue Mar 23, 2004 9:11 pm
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
Aargh!...Also in Win98SE and Win98ME.
Never saw that switch slip in. I know it wasn't there with DOS 1.2 the last time I looked.
It also works with /s to show full path of sub directories
dir *. /s /b
Thanks for the refresher course rullbandspelare

Never saw that switch slip in. I know it wasn't there with DOS 1.2 the last time I looked.

It also works with /s to show full path of sub directories
dir *. /s /b
Thanks for the refresher course rullbandspelare
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!