dir command with File Access

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

Hello all, I hope someone can help me.

How can I list a file's File Access date? Even better, how can I get a
listing of files with an access date later than a given date?

Thanks,

Dave
 
You could use the "DIR /TA" command, or "DIR /TA /A-D" if you want files
only, folders excluded. A simple batch file would look like this:

(Note: Remove the line numbers, use them to identify unwanted line
wraps)

1. @Echo Off
2. SetLocal ENABLEEXTENSIONS
3. Set TARGETFOLDER=%TEMP%
4. Set MINIMUMDATE=07/15/2005
5. For /F %%A In ('Dir "%TARGETFOLDER%" /N /TA /A-D^|Find "/"') Do @If %%A
GTR %MINIMUMDATE% Echo %%A
 
Ignore the last post, I forgot to re-arrange the date elements so they sort
correctly (i.e.: 07/01/2005 needs to be converted to 2005/07/01).

01. @Echo Off
02. SetLocal ENABLEEXTENSIONS
03. Set TARGETFOLDER=%TEMP%
04. Set MINIMUMDATE=07/22/2005
05.
06. For /F %%A In ('Dir "%TARGETFOLDER%" /ta /a-d^|Find "/"') Do @Call
:CheckDate %%A %MINIMUMDATE%
07. GoTo :EOF
08.
09. :CheckDate
10. Set DATE1=%1
11. For /F "tokens=1-3 delims=/" %%A In ('Echo %DATE1%') Do @Set
DATE1=%%C/%%A/%%B
12. Set DATE2=%2
13. For /F "tokens=1-3 delims=/" %%A In ('Echo %DATE2%') Do @Set
DATE2=%%C/%%A/%%B
14. If %DATE1% GTR %DATE2% Echo %DATE1%
15. GoTo :EOF
 
Hello all, I hope someone can help me.

How can I list a file's File Access date? Even better, how can I get a
listing of files with an access date later than a given date?

In 4NT, this will show files with an Access Date on or after 22-Jul-2005
(/[da2005/07/22]) and display that Access Date (/T:a):

DIR /[da2005/07/22] /T:a

4NT's Date Ranges are documented at
<http://jpsoft.com/help/dateranges.htm>. 4NT is a commercial product. I
suspect that a solution for CMD.EXE is a bit more elaborate.

Also, keep in mind that the recording of Access Date can easily be
turned off (NtfsDisableLastAccessUpdate), and is only available on NTFS
drives.
Also, keep in mind that Access Date is only available on NTFS drives,
and even there can easily be turned off (NtfsDisableLastAccessUpdate),
so don't rely on it.
 
In said:
Ignore the last post, I forgot to re-arrange the date elements
so they sort correctly (i.e.: 07/01/2005 needs to be converted
to 2005/07/01).

01. @Echo Off
02. SetLocal ENABLEEXTENSIONS

Suggest that adding
set DIRCMD=
may be wise. Expecially if the local CMD environment is or may be
unknown.

[ ]
 
Mark V said:
In microsoft.public.win2000.cmdprompt.admin Marty List wrote:


Suggest that adding
set DIRCMD=
may be wise. Expecially if the local CMD environment is or may be
unknown.

[ ]


That's a good idea. That's why I added /N to the DIR command, but resetting
DIRCMD would be more thorough.
 
In said:
Mark V said:
In microsoft.public.win2000.cmdprompt.admin Marty List wrote:


Suggest that adding
set DIRCMD=
may be wise. Expecially if the local CMD environment is or may
be unknown.

[ ]


That's a good idea. That's why I added /N to the DIR command,
but resetting DIRCMD would be more thorough.

Yep. I got bitten a few times with portable batch and now include
SETLOCAL
SET DIRCMD=
SET COPYCMD=
routinely to "eliminate the variables" (figuratively and
literally). :-)
 
Back
Top