| 1. |
Solve : Win/Batch: How to display the "seconds" field in last modified date of a file?? |
|
Answer» Hi, I got the error message" 'FORFILES' is not recognized as an internal or external command, it isn't included in XP. Only Vista or later. However it is part of the Windows 2000 Resource Kit. Get it here http://www.dynawell.com/download/reskit/microsoft/win2000/forfiles.zip Unzip it and copy forfiles.exe to: %systemroot%\system32\forfiles.exe and it should work. Where %systemroot% is a system variable normally pointing to "c:\windows". Thanks for your INPUT, but my clients does not allow to install extra programs on their machines. Let's go back to the approach of vbscript. Could anybody teach me how to integrate the vbscript that mentioned by "ghostdog74" into a DOS/Batch file? Code: [Select]Set objFS = CreateObject( "Scripting.FileSystemObject" ) strFile=WScript.Arguments(0) Set objFile = objFS.GetFile(strFile) theDate = objFile.DateLastModified WScript.Echo Second(theDate) Or is there any other alternative to use native Dos command to get the "seconds" field of a file's "last modified date"? Thanks, Thomas Quote from: lwkt on December 29, 2010, 07:54:24 PM Could anybody teach me how to integrate the vbscript that mentioned by Save it somewhere as a .vbs file and call it from the batch file by [path\]name, with the //nologo switch, using the cscript.exe script engine, passing the filename as a parameter (quoted if it contains spaces) Code: [Select]cscript //nologo scriptname.vbs "filename" Note that the file modification time in NTFS or FAT32 is only accurate to 2 seconds anyhow. Are you sure this is the best method? Can't you just examine the last line of the log file and see if it has changed? An accuracy of 2 seconds is not enough as my purpose is to keep track of any update of the log file down to every second. Tracking of the changes on last line of the log file is a good suggestion. Would you mind teach me how to implement in a DOS/batch approach? Thanks, Thomas |
|