I have scripted CleanRecent.bat to delete all items from a specified Recent folder except for shortcut (.lnk)
files of specified file types.
The syntax for using CleanRecent.bat is:
CleanRecent "LocalUserProfilePath" "Extensions" Seconds
where "LocalUserProfilePath" is the path to the user profile folder on the local machine, "Extensions" is a list of file types, separated by spaces, and Seconds is the number of seconds to wait between purges.
I schedule CleanRecent.bat to run in the local Administrator context, while I am logged on as SchulmanJ, so that it runs hidden in the background. Specifically, I schedule:
CleanRecent.bat "c:\Documents and Settings\SchulmanJ" "DOC MDB XLS PPT" 301
CleanRecent.bat contains:
@echo off if \{%3\}==\{\} @echo Syntax: CleanRecent "LocalUserProfilePath" "Extensions" Seconds&exit /b 1 setlocal set userp=%1 set userp="%userp:"=%\Recent" set ext=%2 set sec=%3 set /a sec=100000%sec%%%100000 set /a sec=%sec% + 1 :loop ping -n %sec% 127.0.0.1>nul for /R %userp% %%a in (*.*) do set file=%%a&call :test1 goto loop :test1 set file=%file:&= % for /f "Tokens=2,3 Delims=." %%f in ('@echo %file%') do set p2=%%f&set p3=%%g if /i "%p3%" NEQ "lnk" del /q "%file%"&goto :EOF set OK= for /f "Tokens=*" %%f in ('@echo %p2% ^|findstr /i /l %ext%') do ( set OK=%%f ) if not defined OK del /q "%file%"