You are not logged in.

#1 31 Oct 2007 12:26

//[T.0.P]//
Member
Registered: 12 Aug 2006
Posts: 50

faster way of getting Creation and Access dates for files?

Is there a faster way of getting the dates for Creation and Access for a file than searching for the text through the DIR /T command? I know you can get the last written date by using the paramter %~t1 but you can't with Creation and Access unless you extract from the output of DIR /T. Just wondering if it's possible to get those other two dates by using a paramter like the time switch.

Thanks!

Offline

#2 02 Nov 2007 08:47

bleed
Member
From: Crestwood, KY, USA
Registered: 03 Feb 2007
Posts: 8

Re: faster way of getting Creation and Access dates for files?

@ECHO OFF
ECHO.
SET /P FILENAME=Enter the filename that you wish to view its times.ÿ
IF "%FILENAME%"=="" GOTO :EOF
IF NOT EXIST .\%FILENAME% SET FILENAME= && GOTO :EOF
FOR /F "TOKENS=1-3 DELIMS= " %%A IN ('DIR .\%FILENAME% /T:C ^| FIND /I "%FILENAME%"') DO SET CREATION=%%A %%B %%C
FOR /F "TOKENS=1-3 DELIMS= " %%A IN ('DIR .\%FILENAME% /T:A ^| FIND /I "%FILENAME%"') DO SET ACCESS=%%A %%B %%C
FOR /F "TOKENS=1-3 DELIMS= " %%A IN ('DIR .\%FILENAME% /T:W ^| FIND /I "%FILENAME%"') DO SET WRITTEN=%%A %%B %%C
ECHO.
ECHO %FILENAME%
ECHO Creation     = %CREATION%
ECHO Last Access  = %ACCESS%
ECHO Last Written = %WRITTEN%
SET FILENAME=
SET CREATION=
SET ACCESS=
SET WRITTEN=
PAUSE > NUL:

Last edited by bleed (02 Nov 2007 08:56)

Offline

#3 02 Nov 2007 10:26

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: faster way of getting Creation and Access dates for files?

I think the only way to avoid using DIR like bleeds script is to make the jump to PowerShell

C:\PS>get-itemproperty C:\Test\myfile.doc | format-list

By the way, if you add SETLOCAL to the start of a script you avoid the need for all those SET statements to remove variables at the end.

Offline

#4 04 Nov 2007 03:47

//[T.0.P]//
Member
Registered: 12 Aug 2006
Posts: 50

Re: faster way of getting Creation and Access dates for files?

PowerShell looks alright. Wonder what it can do... I might download it but for now I'll stick to what bleed's got goin' because I'm concentrating on portability.

Thanks for you help, guys!

Offline

Board footer

Powered by