JSI Tip 7720. How can I purge old shortcuts from my Recent folder?


I have scripted PurgeRecent.bat to retain n days of shortcuts in your recent folder.

The syntax for using PurgeRecent.bat is:

PurgeRecent \[age\]

where age is an optional parameter which is the number of days to retains. If omitted, age defaults to 30 days.

You can run PurgeRecent.bat in a logon script, place it in your Startup folder, or schedule it to run in your User Name context.

PurgeRecent.bat uses the following sub-programs, which must be in your path:

UnivDate

JSIDateM

     Date2JD

     JD2Date

NOTE: See How do I purge unwanted items from my Recent folder?

PurgeRecent.bat contains:

@echo off
setlocal
set age=30
if not \{%1\}==\{\} set age=%1
call univdate
call jsidatem %yy% %mm% %dd% - %age%
pushd "%UserProfile%\Recent"
for /f "Tokens=*" %%f in ('dir /b /o-d /a-dhs-h-s') do (
 set file=%%f
 call :doit
)
popd
endlocal
exit /b 0
:doit
set file=%file:(=^(%
set file=%file:)=^)%
for /f "Tokens=1-3 Delims=/ " %%g in ('dir "%file%" /TW /o-d /a-dhs-h-s ^|Findstr /C:"/"') do (
 set month=%%g
 set day=%%h
 set year=%%i
)
if "%year%%month%%day%" LEQ "%AYMD%" del /q "%file%"



Hide comments

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.
Publish