I’ve started on a batch file that Window’s Task Scheduler
can run every Friday to clean up by deleting file bloat. I think my next step is to abstract it into a for loop that can be fed a list of directories, bonus points if I can read that list from an external file as well. (Mainly for security, the manager wants to make sure only they can change the list, but each employee should be able to run it locally.)
:: C:\Users%username%\AppData\Local\Temp
:: C:\Users%username%\AppData\Local\Autodesk\Revit\PacCache
:: C:\Users%username%\AppData\Local\Autodesk\Revit\Autodesk Revit 2023\CollaborationCache
:: C:\Users%username%\AppData\Local\Autodesk\Revit\Autodesk Revit 2023\CefCache
:: C:\Users%username%\AppData\Local\Autodesk\Revit\Autodesk Revit 2023\Journals
:: Delete all files
del /s /q "C:\Users\%username%\Desktop\DeletedWeeklyOnFriday\*.*"
:: Delete all folders
for /d %%p in ("C:\Users\%username%\Desktop\DeletedWeeklyOnFriday\*.*") do rmdir "%%p" /s /q
exit
When I try to loop through the list of files it’s breaking on the spaces
@echo OFF
FOR %%x IN (
1
2
3
Temp
Autodesk\Revit\PacCache
Autodesk\Revit\Autodesk Revit 2020\CollaborationCache
Autodesk\Revit\Autodesk Revit 2020\CefCache
Autodesk\Revit\Autodesk Revit 2020\Journals
Autodesk\Revit\Autodesk Revit 2022\CollaborationCache
Autodesk\Revit\Autodesk Revit 2022\CefCache
Autodesk\Revit\Autodesk Revit 2022\Journals
Autodesk\Revit\Autodesk Revit 2023\CollaborationCache
Autodesk\Revit\Autodesk Revit 2023\CefCache
Autodesk\Revit\Autodesk Revit 2023\Journals
) DO ECHO %%x
PAUSE
I’ve tried back ticks, double quotes and percent signs to escape them, but no luck yet