| 1. |
Solve : plz help me with batch file (check whether new file exists)? |
|
Answer» Hi, @echo offhere's a vbscript Code: [Select]Option Explicit Dim myFolderToSearch,myFile,FileName,OutFile Dim objFSO,objFolder,objOutFile Dim temp myFolderToSearch = "c:\temp" OutFile = "c:\test1\latest.txt" Set objFSO=CreateObject("Scripting.FileSystemObject") If Not objFSO.FileExists(OutFile) Then 'If the checking file does not exist, create Set objOutFile = objFSO.CreateTextFile(OutFile,true) objOutFile.Write "0" objOutFile.Close temp = 0 Else Set objOutFile = objFSO.OpenTextFile(OutFile,1) 'read the file temp = objOutFile.ReadLine 'get value of last date time stamp objOutFile.Close End If For Each myFile In objFSO.GetFolder(myFolderToSearch).Files If objFSO.GetExtensionName(myFile) = "txt" Then If myFile.DateLastModified > CDate(temp) Then temp=myFile.DateLastModified FileName=myFile WScript.Echo "FileName found: " & myFile & ", Time: " & temp End If End If Next Set objOutFile = objFSO.OpenTextFile(OutFile,2) 'write newest objOutFile.Write temp objOutFile.Close Two options have been supplied, if possible could you tell us if the TASK has been overcome?Hi guys, Thank you for your HARD work and helping me.. Its working perfect and once again you. regards, chinna |
|