Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Script to list all files and properties from directory

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,56218
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script to list all files and properties from directory
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Script to list all files and properties from directory - 1/31/2008 2:52:40 PM   
  abracetti

 

Posts: 2
Score: 0
Joined: 1/31/2008
Status: offline
Hi Guys,

I'm trying to create a vbs script to run in a folder of a file server to get some details of all the files in that folder, let's say I have 100 users storing files on this server and they have each one access to only one personal folder on the server, but as USERS they do not worry about saving sapce on the server and do not cleanup their files so the server keeps filling up. I wanted to via script create an excel spreadsheet to list all files with some its properties like: Name, Size, Type, Date Created, Date Modified, Last Accessed and Path.
With this script I'm trying to list files that have not been accessed for a long time and clear them up , since we have a backup of all this. 
I already have a script to list the files on the root of the folder but i also wanted to know what is inside the subfolders......
I haven't used much scripting before but nevertheless I was trying to create this script by myself but was getting to the point where i would have to recall the subroutine too many times and was afraid of allocating too much memory for this script and maybe crash the server , not speaking of running out of rows within the excel file........
The basic script I used is the one below but it doesn't go trough subfolders.......

Can someone shed some light please???

Dim intRow
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1,1).Value = "Name"
objExcel.Cells(1,2).Value = "Size"
objExcel.Cells(1,3).Value = "Type"
objExcel.Cells(1,4).Value = "Date Created"
objExcel.Cells(1,5).Value = "Date Modified"
objExcel.Cells(1,6).Value = "Last Accessed"

For Each strFileName in objFolder.Items
For i = 0 to 6
  
  objExcel.Cells(intRow,i+1).Value = objFolder.GetDetailsOf(strFileName, i)

Next

intRow = intRow + 1
Next
 
 
Post #: 1
 
 RE: Script to list all files and properties from directory - 1/31/2008 11:01:49 PM   
  ehvbs

 

Posts: 2173
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi abracetti,

as I wouldn't touch the Shell.Application with a long pole (bad design/implementation/documentation),
my code uses the FileSystemObject:


      

You'll find some discussion about recursive dir walking here

   http://www.visualbasicscript.com/fb.aspx?m=55650

Feel free to ask, if you need further explanations.

Good luck!

ehvbs

(in reply to abracetti)
 
 
Post #: 2
 
 RE: Script to list all files and properties from directory - 2/3/2008 11:23:26 AM   
  abracetti

 

Posts: 2
Score: 0
Joined: 1/31/2008
Status: offline
Thanks Heaps!

It does the Job perfectly.





(in reply to abracetti)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Script to list all files and properties from directory Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts