diff --git a/NOT WORKING!! RevitRecentNetworkFileCleaner.bat b/NOT WORKING!! RevitRecentNetworkFileCleaner.bat new file mode 100644 index 0000000..4396196 --- /dev/null +++ b/NOT WORKING!! RevitRecentNetworkFileCleaner.bat @@ -0,0 +1,93 @@ +REM THIS FILE IS NOT WORKING!!!! +REM Revit.ini is encoded as UTF-16 however windows cmd is UTF-8 only, so this script should be rewritten in powershell or ither language. +REM I leave it here for historical reasons +@echo off +REM Version: 1.0 +REM Removes network files from recent files from Revit.ini +REM You can set up wich drives to clean from the ini and the folder for local files. It creates a backup before modifying the ini. +REM This script solves a bug in Revit 2019 onward, where File menu freezes for minutes if there is an inaccessible file in the recent file list +REM Created by Peter Gyetvai: gyetpet@gmail.com with the help of the internet + +REM -------- +REM Settings +REM -------- + +REM Revit versions to clean: +REM Separate elements in these list with spaces: +SET REVITVERSIONS=2019 2020 + +REM External drive letters, path from this drives will be cleaned: +REM Separate elements in these list with spaces: +SET EXTERNALPATH=P Q + +REM Clear local files from path: [true/false] +REM From Revit 2019.2 local files of unaccessible servers also freeze the start screen and file menu. If this is set to true, local files will be cleaned as well. +SET CLEARLOCALFILES=true + + +REM ----------------------- +REM Beginning of the script +REM ----------------------- + +chcp 1200 +setlocal enabledelayedexpansion + +(for %%a in (%REVITVERSIONS%) do ( + call :inicheck %%a +)) + +echo Removed problematic lines from Revit.ini + +GOTO :eof + +:inicheck + set currver=%1 + set folder=%appdata%\Autodesk\Revit\Autodesk Revit %currver% + set theini=%folder%\Revit.ini + set thebackup=%theini%.bckp + set tempini=%theini%-temp + + IF EXIST "%theini%" ( + echo Creating backup: %thebackup% + copy /y "%theini%" "%thebackup%" + + if %CLEARLOCALFILES% equ true ( + call :findprojectpath + call :findpathlines + ) else ( + call :findpathlines + ) + ) +EXIT /B + +:findprojectpath + FOR /F "tokens=1,2 delims==" %%G IN ('type "!theini!"') DO ( + if %%G equ ProjectPath ( + echo Found project path: %%H + set path=%%H + set ppath=!path:\=\\! + echo !ppath! + call :dellineandmove File.=!ppath! + + ) + ) +EXIT /B + +:findpathlines + (for %%b in (%EXTERNALPATH%) do ( + echo Finding lines for drive: %%b:\ + set currdrive=%%b:\\ + call :dellineandmove !currdrive! + )) +EXIT /B + +:dellineandmove + echo Deleting line(s) from file with regex: %* + type "!theini!" | findstr /v /r %* > "!tempini!" + echo Moving temp file + move /y "!tempini!" "!theini!" +EXIT /B + +REM ----------------------- +REM End of the script +REM ----------------------- \ No newline at end of file