This one is driving me insane.....
I want a script to read in a variable (Drive Letter)
the script will then read the root and export all the file names to an Access DB including filesize and mod date stamp. It will then do the same for all subfolders and files within them. I can get part of it working but for some reason it will not allow me to include the datestamps.
Here is my script....
'******************************************************
' *************************************************************************
Const ForAppending = 8
Dim fs,folder,wshShell,msg
Set fs = CreateObject("Scripting.FileSystemObject")
Set wshshell = CreateObject("WScript.Shell")
'10
folder="L:\" 'Provide any path here you choose.
Set folder = fs.getfolder(folder)
' **********************************************************************
' Establish Database Connection
' **********************************************************************
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Server_Info;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM SVR_File_Info" , objConnection, _
adOpenStatic, adLockOptimistic
'25
Public FolderCount,FileCount
objRecordset.AddNew
objRecordset("Folder") = Folder 'Inserts Root PAth
objRecordset("SizeInKB") = FormatNumber((Folder.size/1024), 0)
wscript.echo Folder.DateLastModified
'objRecordset("ModDate") = Folder.DateLastModified
'objRecordset("CreateDate") = Folder.DateCreated
objRecordset.Update
ListfoldersandFiles(Folder)
FolderCount=0
ListfoldersandFilesc(Folder)
'36
'objTextFile.WriteLine "******* There are " & FolderCount & " folders and " & FileCount & " files in Folder: " & Folder & " ***************"
'objTextFile.Close
msgbox "Complete"
objRecordset.Close
objConnection.Close
'44
' *****************************************************************
' Sub Routines for File and Folder Recursion
'
' *****************************************************************
Sub ListfoldersandFiles(folder)
For Each File In folder.files
FileCount=FileCount+1 'Filecount Start
objRecordset.AddNew
objRecordset("Folder") = folder
objRecordset("FileName") = File.name ' Inserts Filename within Folder
'54
objRecordset("SizeInKB") = FormatNumber((file.Size/1024), 0)
objRecordset.Update
Next
'objRecordset("FilesinFolder") = folder & ": " & FileCount
FileCount=0
For Each subfolder In folder.subfolders
objRecordset.AddNew
objRecordset("Folder") = Subfolder
objRecordset("SizeInKB") = FormatNumber((Subfolder.Size/1024), 0)
objRecordset.Update
Foldercount=FolderCount+1 'FileCount Continue
'66
ListFoldersandfiles(Subfolder)
Next
End Sub
' ***********************************************************************
' Sub Routines for File and Folder Count
'
' ***********************************************************************
Sub ListfoldersandFilesc(folder)
'76
For Each File In folder.files
FileCount=FileCount+1
'wscript.echo File.name
Next
For Each subfolder In folder.subfolders
'wscript.echo Subfolder
Foldercount=FolderCount+1
ListFoldersandfilesc(Subfolder)
'86
Next
End Sub
' *****************************************************
I want a script to read in a variable (Drive Letter)
the script will then read the root and export all the file names to an Access DB including filesize and mod date stamp. It will then do the same for all subfolders and files within them. I can get part of it working but for some reason it will not allow me to include the datestamps.
Here is my script....
'******************************************************
' *************************************************************************
Const ForAppending = 8
Dim fs,folder,wshShell,msg
Set fs = CreateObject("Scripting.FileSystemObject")
Set wshshell = CreateObject("WScript.Shell")
'10
folder="L:\" 'Provide any path here you choose.
Set folder = fs.getfolder(folder)
' **********************************************************************
' Establish Database Connection
' **********************************************************************
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Server_Info;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM SVR_File_Info" , objConnection, _
adOpenStatic, adLockOptimistic
'25
Public FolderCount,FileCount
objRecordset.AddNew
objRecordset("Folder") = Folder 'Inserts Root PAth
objRecordset("SizeInKB") = FormatNumber((Folder.size/1024), 0)
wscript.echo Folder.DateLastModified
'objRecordset("ModDate") = Folder.DateLastModified
'objRecordset("CreateDate") = Folder.DateCreated
objRecordset.Update
ListfoldersandFiles(Folder)
FolderCount=0
ListfoldersandFilesc(Folder)
'36
'objTextFile.WriteLine "******* There are " & FolderCount & " folders and " & FileCount & " files in Folder: " & Folder & " ***************"
'objTextFile.Close
msgbox "Complete"
objRecordset.Close
objConnection.Close
'44
' *****************************************************************
' Sub Routines for File and Folder Recursion
'
' *****************************************************************
Sub ListfoldersandFiles(folder)
For Each File In folder.files
FileCount=FileCount+1 'Filecount Start
objRecordset.AddNew
objRecordset("Folder") = folder
objRecordset("FileName") = File.name ' Inserts Filename within Folder
'54
objRecordset("SizeInKB") = FormatNumber((file.Size/1024), 0)
objRecordset.Update
Next
'objRecordset("FilesinFolder") = folder & ": " & FileCount
FileCount=0
For Each subfolder In folder.subfolders
objRecordset.AddNew
objRecordset("Folder") = Subfolder
objRecordset("SizeInKB") = FormatNumber((Subfolder.Size/1024), 0)
objRecordset.Update
Foldercount=FolderCount+1 'FileCount Continue
'66
ListFoldersandfiles(Subfolder)
Next
End Sub
' ***********************************************************************
' Sub Routines for File and Folder Count
'
' ***********************************************************************
Sub ListfoldersandFilesc(folder)
'76
For Each File In folder.files
FileCount=FileCount+1
'wscript.echo File.name
Next
For Each subfolder In folder.subfolders
'wscript.echo Subfolder
Foldercount=FolderCount+1
ListFoldersandfilesc(Subfolder)
'86
Next
End Sub
' *****************************************************