Ok, updated the code I used above. It now reads all filenames and not just the last alphabetical one. No need for dirplus UDF. It still uses count files to see if the folder is not empty.
Just need to find a way to get rid of the . and .. rows.
About reading an existing excel sheet and finding if the line already exists you could use ReadExcel2() - Reads from excel I think. Did not use it yet because I don't have that much time right now to find out how to use it inside this script.
Code:
Break on
Call @SCRIPTDIR + "\countfiles().udf"
$folder = "c:\new folder\"
$count = countfiles($folder, "*.*")
$rc = Exist ($folder)
If $rc = "1" AND $count <> "0"
$oXL = CreateObject("EXCEL.application")
If @error = 0
$oXL.Visible = 1
$rc = $oXL.Workbooks.Add
$array = "Filename", "Creation date"
$oXL.Range("A1:B1").Value = $array
$fileName = Dir($folder + "*.*")
While $FileName <> "" AND @ERROR = 0
$i = $i + 1
$filetime = GetFileTime($folder + $filename,1)
$oXL.Cells(($i+1),1).Value = $filename
$oXL.Cells(($i+1),2).Value = $filetime
$FileName = Dir()
Loop
$oXL.Range("A1:B1").Font.Bold = 1
$Rc = $oXL.Range("A1:B1").EntireColumn.AutoFit
$oXL.UserControl = 1
Else
? @error + " / " @serror
EndIf
Else
?"Folder: " + $folder + " does not exist or is empty."
Sleep 3
EndIf
Edited by Mart (2005-09-05 07:48 PM)
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.