Search : in
By :

List all Folders from Diff. Directory

mhel_0414, on Sep 19, 2009 10:52:37 am BST 
 Report this message to moderators

Hello,

It's me again, can anyone help me modify this code.
My aim is to list all the folders with its subfolders. I have 3 locations/directories that need to be listed.
I put all the locations on the same workbook (it's on sheet2("folder_path").
The sheet serves as my database for path and owner name (I can still add new locations and names on this sheet.
Can anyone help me please.
Someone sent me this code but I can't modify it to add my other 2 location.

here's the code:

===========================================
Sub CreateList()

Application.ScreenUpdating = False
ThisWorkbook.Worksheets.Add

With Cells(1, 1)
.Value = "Folder contents of:"
.Font.Bold = True
.Font.Size = 11
End With

'Cells(3, 1).Value = "Owner:"
Cells(4, 1).Value = "Folder Name:"
Cells(4, 2).Value = "Size:"
Cells(4, 3).Value = "Subfolders:"
Cells(4, 4).Value = "Files:"
Cells(4, 5).Value = "Date Modified:"
Cells(4, 6).Value = "Date Created:"
Range("A4:F4").Font.Bold = True
ListFolders (Worksheets("folder_path").Cells(1, 1).Value), True
'ListFolders (Worksheets(2).Cells(2, 1).Value), True
Application.ScreenUpdating = True


End Sub

Sub ListFolders(SourceFolderName As String, IncludeSubfolders As Boolean)
' lists information about the folders in SourceFolder
Dim FSO As Scripting.FileSystemObject
Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder
Dim r As Long
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(SourceFolderName)
' display folder properties
r = Cells(Rows.Count, 1).End(xlUp).Row + 1
'Cells(r, 1).Value = SourceFolder.ParentFolder
Cells(r, 1).Value = SourceFolder.Name
Cells(r, 2).Value = SourceFolder.Size
Cells(r, 3).Value = SourceFolder.SubFolders.Count
Cells(r, 4).Value = SourceFolder.Files.Count
Cells(r, 5).Value = SourceFolder.DateLastModified
Cells(r, 6).Value = SourceFolder.DateCreated

With Cells(2, 1)
.Value = (Worksheets("folder_path").Cells(1, 2).Value)
End With

If IncludeSubfolders Then
For Each SubFolder In SourceFolder.SubFolders
ListFolders SubFolder.Path, True
Next SubFolder
Set SubFolder = Nothing
End If
Columns("A:F").AutoFit
Set SourceFolder = Nothing
Set FSO = Nothing
ActiveWorkbook.Saved = False


End Sub
==============================================

These are the contents of sheet "folder_path".

C:\Documents and Settings\administrator\Desktop\fileinfo_test\ Celestino
C:\Documents and Settings\administrator\Desktop\fileinfo_test\testing\ Ryan
C:\Documents and Settings\administrator\Desktop\laptop-mheds\antivirus\Symantec\cd2\ Ruel


Looking forward that somebody will help me.
Thank you in advance..

mhel

Configuration: Windows XP Internet Explorer 6.0

Best answers for « List all Folders from Diff. Directory » in :
Warning: rmdir(..): Directory not empty Show Warning: rmdir(..): Directory not empty If you are attempting to delete a PHP file and that you get the error message: Warning: rmdir(..): Directory not emptyť. This might mean that the directory is not empty. To be able to...
How to use the tar command ShowHow to use the tar command Archiving files with “tar” Archiving folder (or directory) with “tar” Unpacking file with tar Unpack the file with tar Unpacking specific files with "tar" Archiving files with “tar” The "tar"...
[MS-Dos]List the contents of a directory in a file Show[MS-Dos]List the contents of a directory in a file Intro Explanation Intro It may be convenient to make the listing of one or more directories in a file, to make a catalog of files. Under MS-DOS (or Windows by opening a...
Remove Directory Links from Favorites ShowRemove Directory Links from favourites Hiding Links folder Permanently delete the Links folder Despite deleting the folder "Links" in favorites, this one is regenerated automatically when you restart the computer. There are two...
Download AVD FileList ShowDescription The application is designed by AVLAN Design. AVD FileList is a tool that creates list of files in a folder or directory. Simple and easy to use, the application has been awarded from various places. The application allows you to create...
Download Change Folder Icons ShowAs its name suggests, Change Folder Icons will allow you to search and replace quickly the standard icon of a folder or disk. Easy to use, simply press the right button of the mouse on a folder by selecting the item “Change Folder Icon”. The icons...
UNIX Commands ShowTable of the main UNIX commands Unix Commands Description Options ls lists the content of a directory -a Displays all files, including hidden files -I Displays a...
Directory ShowWhat is a directory? A directory (also known as a folder) is an IT element that can contain files. Imagine a large dresser containing drawers in which files or other drawers are stored. A directory can in fact contain: files other...
File sharing in Windows XP ShowAdvantages File sharing involves making the content of one or more directories available through the network. All Windows systems have standard devices making it easy to share the content of a directory. However, file sharing may lead to security...