'Macro is designed to list all files in folder and their sub folder with path
'-----------------------------------------------------------------------------------------------------
Sub Moving_Similar_FileType()
Range("A1").Select
Call fso_file_type(InputBox("Enter the folder Path: "))
MsgBox "done!!"
End Sub
-------------------------------------------------------------------------------------------------------------------------
Sub fso_file_type(path As String)
Dim fso As New FileSystemObject 'Intializing file system object
Dim fl As File
Dim fld, subfolder As Folder
Set fld = fso.GetFolder(path)
For Each fl In fld.Files ' Loop to list all files and thier type in that folder
Sheet1.Range("A" & ActiveCell.Row).Value = fl.Name
Sheet1.Range("B" & ActiveCell.Offset(0, 1).Row).Value = fl.ParentFolder
ActiveCell.Offset(1, 0).Select
Next
For Each subfolder In fld.SubFolders 'Recursive to list all files folder within folder
Call fso_file_type(subfolder.path)
Next
End Sub
'-----------------------------------------------------------------------------------------------------
Sub Moving_Similar_FileType()
Range("A1").Select
Call fso_file_type(InputBox("Enter the folder Path: "))
MsgBox "done!!"
End Sub
-------------------------------------------------------------------------------------------------------------------------
Sub fso_file_type(path As String)
Dim fso As New FileSystemObject 'Intializing file system object
Dim fl As File
Dim fld, subfolder As Folder
Set fld = fso.GetFolder(path)
For Each fl In fld.Files ' Loop to list all files and thier type in that folder
Sheet1.Range("A" & ActiveCell.Row).Value = fl.Name
Sheet1.Range("B" & ActiveCell.Offset(0, 1).Row).Value = fl.ParentFolder
ActiveCell.Offset(1, 0).Select
Next
For Each subfolder In fld.SubFolders 'Recursive to list all files folder within folder
Call fso_file_type(subfolder.path)
Next
End Sub
No comments:
Post a Comment