FSO / Files in a Folder
'==========================================================================
' NAME: FSOFilesInFolder.vbs
' AUTHOR: Neal Walters
' DATE : 3/26/2005
' http://VBScript-Training.com
'==========================================================================
Option Explicit
WScript.Echo ShowFolderList("c:\Documents and Settings\nwalters\My Documents\Camtasia Studio\VBScript-Training2")
WScript.Echo "------------------"
'WScript.Echo ShowFolderList("c:\") 'Gets permission denied on some folder?
'WScript.Echo "------------------"
Function ShowFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
s = " There are " & fc.Count & " files in this directory." & VbCrLf & VbCrlf
For Each f1 In fc
s = s & "filename=" & f1.name & " Created=" & f1.DateCreated & " Last Modified:" & f1.DateLastModified
s = s & " size=" & f1.size & " path=" & f1.path
s = s & VbCrLf
Next
ShowFolderList = s
End Function
Make copy of most recent file in directory
I needed to FTP a specific file on a nightly basis.
My backup utility put the date/time into the filename itself, for example: STUDENTS_FullDBBackup_200904010320.BAK
So rather than scripting the FTP backup, I wanted to always download a file such as STUDENTS_FullDBBackup.BAK.
This VBScript copies the most recent .BAK file and drops the date/time out of the filename.
It could be modified for other purposes. It include a handy function called GetMostRecentFile.
|