@echo off & setlocal enableextensions
::
:: Get the file name
if [%1]==[] (echo Usage: %~f0 FileName & goto :EOF)
if not exist "%~f1" (echo File %~f1 not found & goto :EOF)
set fname_=%~f1
::
:: Display the information
for /f %%f in ('dir "%fname_%" /s /b /-c /a:-d-s-h') do echo %%~ff
echo Created:
for /f "skip=5 tokens=*" %%f in (
'dir "%fname_%" /tc /-c /a:-d-s-h^|find /v "(s)"') do echo %%f
echo Last written:
for /f "skip=5 tokens=*" %%f in (
'dir "%fname_%" /tw /-c /a:-d-s-h^|find /v "(s)"') do echo %%f
echo Last accessed:
for /f "skip=5 tokens=*" %%f in (
'dir "%fname_%" /ta /-c /a:-d-s-h^|find /v "(s)"') do echo %%f
endlocal & goto :EOF
The output might be something like
D:\TEST>cmdfaq batfaq.bat
D:\TEST\BATFAQ.BAT
Created:
14.11.2003 04:06 118 BATFAQ.BAT
Last written:
19.02.2004 13:11 118 BATFAQ.BAT
Last accessed:
21.02.2004 16:52 118 BATFAQ.BAT
Depending on what exactly we want, the above solution is not
necessarily satisfactory. The VBS assisted solution below put the
information first into accessible environment variables.
Furthermore, it includes the seconds in the file time stamp.
@echo off & setlocal enableextensions
::
:: Get the file name
if [%1]==[] (echo Usage: %~f0 FileName & goto :EOF)
if not exist "%~f1" (echo File %~f1 not found & goto :EOF)
set fname_=%~f1
::
:: Build a Visual Basic Script
findstr "'VBS" "%~f0"|findstr /v "findstr" > tmp$$$.vbs
::
:: Run the Visual Basic Script
cscript //nologo tmp$$$.vbs
::
:: Call the command line script wchich the script host built
call tmp$$$.cmd
::
:: Clean up
for %%f in (tmp$$$.vbs tmp$$$.cmd) do if exist %%f del %%f
::
:: Demonstrate the result
echo %fname_%
echo Size: %~z1 bytes
echo Created: %fdc%
echo Last modified: %flm%
echo Last accessed: %fla%
::
endlocal & goto :EOF
'
'................................................................
'The Visual Basic Script
'
Const ForReading = 1, ForWriting = 2, ForAppending = 8 'VBS
Dim FileName, FSO, fin, fout 'VBS
Set WshShell = WScript.CreateObject("WScript.shell") 'VBS
Set FSO = CreateObject("Scripting.FileSystemObject") 'VBS
'
FileName=WshShell.ExpandEnvironmentStrings("%fname_%") 'VBS
Set fin = FSO.GetFile(FileName) 'VBS
'
Set fout = FSO.OpenTextFile("tmp$$$.cmd", ForWriting, true) 'VBS
fout.WriteLine "@set fdc=" & fin.DateCreated 'VBS
fout.WriteLine "@set flm=" & fin.DateLastModified 'VBS
fout.WriteLine "@set fla=" & fin.DateLastAccessed 'VBS
fout.Close 'VBS
The output might be something like
D:\TEST>cmdfaq batfaq.bat
D:\TEST\BATFAQ.BAT
Size: 118 bytes
Created: 14.11.2003 04:06:54
Last modified: 19.02.2004 13:11:32
Last accessed: 21.02.2004 16:52:49
All the best, Timo
--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip
> for /f "skip=5 tokens=*" %%f in (
> 'dir "%fname_%" /tw /-c /a:-d-s-h^|find /v "(s)"') do echo %%f
> echo Last accessed:
You may want to consider xcopy with /l and /d switches
--
Marco
Marco, please elaborate and exemplify. I fail to see a connection.
It might be worth checking, and should be worth stating, whether these
date/times are local or GMT/UTC; and investigating whether there are
any problems with files that are no longer located in their time zone
of creation (NT & 98 may differ).
filgen32 /#3:#C#R#W#F ac*.htm
2004-02-18 13:53:09 2004-02-24 00:00:00 2004-02-18 13:53:10 ACRONYMS.HTM
For me, the Access Date is plainly spurious.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>.
Do not Mail News to me. Before a reply, quote with ">" or "> " (SoRFC1036)