Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-14-2014, 03:51 AM
josianne josianne is offline list folders and files using .vbs file Windows 7 32bit list folders and files using .vbs file Office 2010 32bit
Novice
list folders and files using .vbs file
 
Join Date: Aug 2014
Posts: 2
josianne is on a distinguished road
Default list folders and files using .vbs file

Hello guys!
I'm very new on programming but I'm enjoying it so far .


I need help to make a vbs file that returns a list of files and subfolders of main folder
SO FAR I HAVE THIS (but it doesnt separates the fields in different columns)

Code:
Dim fso
Dim ObjOutFile 

Set fso = CreateObject("Scripting.FileSystemObject") 

Set ObjOutFile = fso.CreateTextFile("OutputFiles.csv")

ObjOutFile.WriteLine("Type,File Name,File Path")

GetFiles("C:\Intel") 

ObjOutFile.Close 
WScript.Echo("Completed")
Function GetFiles(FolderName) 
On Error Resume Next 
Dim ObjFolder
Dim ObjSubFolders 
Dim ObjSubFolder 
Dim ObjFiles 
Dim ObjFile 
Set ObjFolder = fso.GetFolder(FolderName)
Set ObjFiles = ObjFolder.Files 

For Each ObjFile In ObjFiles 
ObjOutFile.WriteLine("File," & ObjFile.Name & "," & ObjFile.Path) 
Next 

Set ObjSubFolders = ObjFolder.SubFolders 
For Each ObjFolder In ObjSubFolders 

ObjOutFile.WriteLine("Folder," & ObjFolder.Name & "," & ObjFolder.Path) 

GetFiles(ObjFolder.Path) 
Next 
End Function

Thanks in advance all you guys!
You'll have a very thankfull girl posting here!
Reply With Quote
  #2  
Old 08-14-2014, 01:39 PM
whatsup whatsup is offline list folders and files using .vbs file Windows 7 64bit list folders and files using .vbs file Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Hi

Quote:
...(but it doesnt separates the fields in different columns)
Actually I don't know what you mean. A .csv file hasn't got any columns. Only if you open the file in excel it will show the contains separated in columns.
Maybe you can give us a hint, what you expect the .csv look like?
Reply With Quote
  #3  
Old 08-18-2014, 02:13 AM
josianne josianne is offline list folders and files using .vbs file Windows 7 32bit list folders and files using .vbs file Office 2010 32bit
Novice
list folders and files using .vbs file
 
Join Date: Aug 2014
Posts: 2
josianne is on a distinguished road
Default

Hi whatsup!
the .csv file generates an output file
(Microsoft Excel Comma Separated Values File)
than kyou so much for any help!
Reply With Quote
  #4  
Old 08-18-2014, 03:03 PM
whatsup whatsup is offline list folders and files using .vbs file Windows 7 64bit list folders and files using .vbs file Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Hi josianne

Before going into details with your generated .csv - what prevents you from writing the results to a normal Excel-sheet, saving it afterwards as .csv? I think it would be the easier way.
If for some reason this doesn't suit you, please post the complete code, and tell what problem you got at the end.
I will need to have it tested just by the look of the part you posted I can't see anything wrong
Reply With Quote
Reply

Tags
file, folder, list



Similar Threads
Thread Thread Starter Forum Replies Last Post
The powerpoint icon on the task bar hides pptx files in the recent files list Innovationgame PowerPoint 0 11-13-2013 09:03 AM
copy, sync files across 2 folders 1 pc spgprivate Office 0 06-20-2013 08:41 AM
How to re-link default email acct folders to default Outlook Data File folders? RDA1959 Outlook 0 03-26-2012 10:55 AM
Macro to List out all the Sub folders Ram1989 Excel Programming 0 02-27-2012 12:33 AM
list folders and files using .vbs file Letters change size in folders list nsv Outlook 1 08-19-2010 03:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft