JSI Tip 1119. When was FileName.ext last accessed?.

To see the answer, type:

dir <Drive:>\Folder\FileName.ext /N /O:D /T:A

To return the answer in the LstADte environment variable, in YYYYMMDD format:

call LastADte <Drive:>\Folder\FileName.ext

where LastADte.bat contains:

@echo off
set LstADte=
if not exist %1 goto syntax
for /f "Skip=4 Tokens=1-5* Delims=/ " %%a in ('dir %1 /N /O:D /T:A') do  call :file %%a %%b %%c %%d %%e %%f
endlocal & set LstADte=%LstADte%
goto end
@echo File Not Found: %1
goto end
if "%6"=="" goto end
set FMM=%1
set FDD=%2
set  FYY=20%3
if "%3" GTR "69" set FYY=19%3
set LstADte=%FYY%%FMM%%FDD%
To archive based upon Last Access Date, modify the last Dir in JSIOLD.BAT From:

for /f "Tokens=1-4* Delims=/ " %%a in ('dir %1 /N') do call :jsioldd %1 %%a %%b %%c %%d %%e


for /f "Tokens=1-4* Delims=/ " %%a in ('dir %1 /N /O:D /T:A') do call :jsioldd %1 %%a %%b %%c %%d %%e

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.