determine last time file/folder was modified
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Newsgroups: microsoft.public.scripting.vbscript
From:
Jeremy <Jer... @discussions.microsoft.com>
Date: Sat, 7 Nov 2009 05:21:01 -0800
Local: Sat, Nov 7 2009 1:21 pm
Subject: determine last time file/folder was modified
I found a script on the net that searches a folder for the names of
subfolders and files and pumps that information to a log file. I have
modified the script to gather more info and to export the data to an Excel
spreadsheet. I just wanted to get some feedback on it. Thanks, Jeremy
----------------------------------------------------------------------- 'Purpose of this script is to recursively search a directory 'to return the following info about subfolders and subfiles 'Date Created, Date Last Accessed, Date Last Modified, 'Name, Path, Size and Type. 'And to massage that all into an Excel spread sheet
Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForAppending = 2 Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject") 'LogFile = "f:\jeremy-data\documents\exportme.log" 'Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(logfile, 2, True)
Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Date Created" objExcel.Cells(1, 2).Value = "Date Last Accessed" objExcel.Cells(1, 3).Value = "Date Last Modified" objExcel.Cells(1, 4).Value = "Name" objExcel.Cells(1, 5).Value = "Path" objExcel.Cells(1, 6).Value = "Size" objExcel.Cells(1, 7).Value = "Type"
objStartFolder = "f:\jeremy-data\documents\"
Set objFolder = objFSO.GetFolder(objStartFolder) 'objLogFile.Write objFolder.Path 'objLogFile.Writeline objExcel.Cells(intRow, 1).Value = objFolder.DateCreated objExcel.Cells(intRow, 2).Value = objFolder.DateLastAccessed objExcel.Cells(intRow, 3).Value = objFolder.DateLastModified objExcel.Cells(intRow, 4).Value = objFolder.Name objExcel.Cells(intRow, 5).Value = objFolder.Path objExcel.Cells(intRow, 7).Value = objFolder.Type intRow = intRow + 1
Set colFiles = objFolder.Files For Each objFile in colFiles ' objLogFile.Write objFile.Name 'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = objFile.DateCreated objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed objExcel.Cells(intRow, 3).Value = objFile.DateLastModified objExcel.Cells(intRow, 4).Value = objFile.Name objExcel.Cells(intRow, 5).Value = objFile.Path objExcel.Cells(intRow, 6).Value = objFolder.Size objExcel.Cells(intRow, 7).Value = objFile.Type intRow = intRow + 1
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder) For Each Subfolder in Folder.SubFolders 'objLogFile.Write Subfolder.Path 'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = subFolder.DateCreated objExcel.Cells(intRow, 2).Value = subFolder.DateLastAccessed objExcel.Cells(intRow, 3).Value = subFolder.DateLastModified objExcel.Cells(intRow, 4).Value = subFolder.Name objExcel.Cells(intRow, 5).Value = subFolder.Path objExcel.Cells(intRow, 6).Value = objFolder.Size objExcel.Cells(intRow, 7).Value = subFolder.Type intRow = intRow + 1
Set objFolder = objFSO.GetFolder(Subfolder.Path) Set colFiles = objFolder.Files
For Each objFile in colFiles 'objLogFile.Write objFile.Name 'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = objFile.DateCreated objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed objExcel.Cells(intRow, 3).Value = objFile.DateLastModified objExcel.Cells(intRow, 4).Value = objFile.Name objExcel.Cells(intRow, 5).Value = objFile.Path objExcel.Cells(intRow, 6).Value = objFolder.Size objExcel.Cells(intRow, 7).Value = objFile.Type intRow = intRow + 1 Next ShowSubFolders Subfolder Next End Sub
objLogFile.Close
wscript.echo "Done!"
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: microsoft.public.scripting.vbscript
From: Randi R
Date: Sun, 08 Nov 2009 10:05:25 -0800
Local: Sun, Nov 8 2009 6:05 pm
Subject: Development of a script to find latest created/modified files on a computer or in a folder
Here is another script I found that finds the latest file - <a href="http://www.biterscripting.com/LearningScripting/Lesson4.html ">http://www.biterscripting.com/LearningScripting/Lesson4.html </a> .
Look at the bottom of the page for the Script latest.txt . This is actually a tutorial, so he explains how to develop this script (or a similar script) step by step.
Jeremy wrote:
determine last time file/folder was modified
07-Nov-09
I found a script on the net that searches a folder for the names of subfolders and files and pumps that information to a log file. I have modified the script to gather more info and to export the data to an Excel spreadsheet. I just wanted to get some feedback on it. Thanks, Jeremy
----------------------------------------------------------------------- 'Purpose of this script is to recursively search a directory 'to return the following info about subfolders and subfiles 'Date Created, Date Last Accessed, Date Last Modified, 'Name, Path, Size and Type. 'And to massage that all into an Excel spread sheet
Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForAppending = 2 Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject") 'LogFile = "f:\jeremy-data\documents\exportme.log" 'Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(logfile, 2, True)
Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Date Created" objExcel.Cells(1, 2).Value = "Date Last Accessed" objExcel.Cells(1, 3).Value = "Date Last Modified" objExcel.Cells(1, 4).Value = "Name" objExcel.Cells(1, 5).Value = "Path" objExcel.Cells(1, 6).Value = "Size" objExcel.Cells(1, 7).Value = "Type"
objStartFolder = "f:\jeremy-data\documents\"
Set objFolder = objFSO.GetFolder(objStartFolder) 'objLogFile.Write objFolder.Path 'objLogFile.Writeline objExcel.Cells(intRow, 1).Value = objFolder.DateCreated objExcel.Cells(intRow, 2).Value = objFolder.DateLastAccessed objExcel.Cells(intRow, 3).Value = objFolder.DateLastModified objExcel.Cells(intRow, 4).Value = objFolder.Name objExcel.Cells(intRow, 5).Value = objFolder.Path objExcel.Cells(intRow, 7).Value = objFolder.Type intRow = intRow + 1
Set colFiles = objFolder.Files For Each objFile in colFiles ' objLogFile.Write objFile.Name 'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = objFile.DateCreated objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed objExcel.Cells(intRow, 3).Value = objFile.DateLastModified objExcel.Cells(intRow, 4).Value = objFile.Name objExcel.Cells(intRow, 5).Value = objFile.Path objExcel.Cells(intRow, 6).Value = objFolder.Size objExcel.Cells(intRow, 7).Value = objFile.Type intRow = intRow + 1
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder) For Each Subfolder in Folder.SubFolders 'objLogFile.Write Subfolder.Path 'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = subFolder.DateCreated objExcel.Cells(intRow, 2).Value = subFolder.DateLastAccessed objExcel.Cells(intRow, 3).Value = subFolder.DateLastModified objExcel.Cells(intRow, 4).Value = subFolder.Name objExcel.Cells(intRow, 5).Value = subFolder.Path objExcel.Cells(intRow, 6).Value = objFolder.Size objExcel.Cells(intRow, 7).Value = subFolder.Type intRow = intRow + 1
Set objFolder = objFSO.GetFolder(Subfolder.Path) Set colFiles = objFolder.Files
For Each objFile in colFiles 'objLogFile.Write objFile.Name 'objLogFile.Writeline
objExcel.Cells(intRow, 1).Value = objFile.DateCreated objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed objExcel.Cells(intRow, 3).Value = objFile.DateLastModified objExcel.Cells(intRow, 4).Value = objFile.Name objExcel.Cells(intRow, 5).Value = objFile.Path objExcel.Cells(intRow, 6).Value = objFolder.Size objExcel.Cells(intRow, 7).Value = objFile.Type intRow = intRow + 1 Next ShowSubFolders Subfolder Next End Sub
objLogFile.Close
Previous Posts In This Thread:
EggHeadCafe - Software Developer Portal of Choice Retrieve Hardware Identifiers in C# with WMI http://www.eggheadcafe.com/tutorials/aspnet/bb5160bf-3459-4397-bc59-d...
You must
Sign in before you can post messages.
You do not have the permission required to post.
Newsgroups: microsoft.public.scripting.vbscript
From:
Jeremy <Jer... @discussions.microsoft.com>
Date: Wed, 11 Nov 2009 07:46:07 -0800
Local: Wed, Nov 11 2009 3:46 pm
Subject: RE: Development of a script to find latest created/modified files on a
Thnaks, the site looks promissing!
"Randi R" wrote:
> Here is another script I found that finds the latest file - <a href="http://www.biterscripting.com/LearningScripting/Lesson4.html ">http://www.biterscripting.com/LearningScripting/Lesson4.html </a> .
> Look at the bottom of the page for the Script latest.txt . This is actually a tutorial, so he explains how to develop this script (or a similar script) step by step.
> Jeremy wrote:
> determine last time file/folder was modified > 07-Nov-09
> I found a script on the net that searches a folder for the names of > subfolders and files and pumps that information to a log file. I have > modified the script to gather more info and to export the data to an Excel > spreadsheet. I just wanted to get some feedback on it. Thanks, Jeremy
> ----------------------------------------------------------------------- > 'Purpose of this script is to recursively search a directory > 'to return the following info about subfolders and subfiles > 'Date Created, Date Last Accessed, Date Last Modified, > 'Name, Path, Size and Type. > 'And to massage that all into an Excel spread sheet
> Set objFSO = CreateObject("Scripting.FileSystemObject") > Const ForAppending = 2 > Dim objFSO:Set objFSO = CreateObject("Scripting.FileSystemObject") > 'LogFile = "f:\jeremy-data\documents\exportme.log" > 'Dim objLogFile:Set objLogFile = objFSO.CreateTextFile(logfile, 2, True)
> Set objExcel = CreateObject("Excel.Application") > objExcel.Visible = True > objExcel.Workbooks.Add
> intRow = 2
> objExcel.Cells(1, 1).Value = "Date Created" > objExcel.Cells(1, 2).Value = "Date Last Accessed" > objExcel.Cells(1, 3).Value = "Date Last Modified" > objExcel.Cells(1, 4).Value = "Name" > objExcel.Cells(1, 5).Value = "Path" > objExcel.Cells(1, 6).Value = "Size" > objExcel.Cells(1, 7).Value = "Type"
> objStartFolder = "f:\jeremy-data\documents\"
> Set objFolder = objFSO.GetFolder(objStartFolder) > 'objLogFile.Write objFolder.Path > 'objLogFile.Writeline > objExcel.Cells(intRow, 1).Value = objFolder.DateCreated > objExcel.Cells(intRow, 2).Value = objFolder.DateLastAccessed > objExcel.Cells(intRow, 3).Value = objFolder.DateLastModified > objExcel.Cells(intRow, 4).Value = objFolder.Name > objExcel.Cells(intRow, 5).Value = objFolder.Path > objExcel.Cells(intRow, 7).Value = objFolder.Type > intRow = intRow + 1
> Set colFiles = objFolder.Files > For Each objFile in colFiles > ' objLogFile.Write objFile.Name > 'objLogFile.Writeline
> objExcel.Cells(intRow, 1).Value = objFile.DateCreated > objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed > objExcel.Cells(intRow, 3).Value = objFile.DateLastModified > objExcel.Cells(intRow, 4).Value = objFile.Name > objExcel.Cells(intRow, 5).Value = objFile.Path > objExcel.Cells(intRow, 6).Value = objFolder.Size > objExcel.Cells(intRow, 7).Value = objFile.Type > intRow = intRow + 1
> Next
> ShowSubfolders objFSO.GetFolder(objStartFolder)
> Sub ShowSubFolders(Folder) > For Each Subfolder in Folder.SubFolders > 'objLogFile.Write Subfolder.Path > 'objLogFile.Writeline
> objExcel.Cells(intRow, 1).Value = subFolder.DateCreated > objExcel.Cells(intRow, 2).Value = subFolder.DateLastAccessed > objExcel.Cells(intRow, 3).Value = subFolder.DateLastModified > objExcel.Cells(intRow, 4).Value = subFolder.Name > objExcel.Cells(intRow, 5).Value = subFolder.Path > objExcel.Cells(intRow, 6).Value = objFolder.Size > objExcel.Cells(intRow, 7).Value = subFolder.Type > intRow = intRow + 1
> Set objFolder = objFSO.GetFolder(Subfolder.Path) > Set colFiles = objFolder.Files
> For Each objFile in colFiles > 'objLogFile.Write objFile.Name > 'objLogFile.Writeline
> objExcel.Cells(intRow, 1).Value = objFile.DateCreated > objExcel.Cells(intRow, 2).Value = objFile.DateLastAccessed > objExcel.Cells(intRow, 3).Value = objFile.DateLastModified > objExcel.Cells(intRow, 4).Value = objFile.Name > objExcel.Cells(intRow, 5).Value = objFile.Path > objExcel.Cells(intRow, 6).Value = objFolder.Size > objExcel.Cells(intRow, 7).Value = objFile.Type > intRow = intRow + 1 > Next > ShowSubFolders Subfolder > Next > End Sub
> objLogFile.Close
> Previous Posts In This Thread:
> EggHeadCafe - Software Developer Portal of Choice > Retrieve Hardware Identifiers in C# with WMI > http://www.eggheadcafe.com/tutorials/aspnet/bb5160bf-3459-4397-bc59-d... > .
You must
Sign in before you can post messages.
You do not have the permission required to post.