Revit Architecture Forum
Welcome to Autodesk’s Revit Architecture Forums. Share your knowledge, ask questions, and explore popular Revit Architecture topics.
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Best method for cleaning backup families

5 ANTWORTEN 5
Antworten
Nachricht 1 von 6
Marcus.Isacsson
1069 Aufrufe, 5 Antworten

Best method for cleaning backup families

Hi fellas!

What's your best method for cleaning backups from your Revit families?
We have a *.bat file but it only cleans the current folder, guess there's a better way.

Bat script
"del *.00??.rfa /S /F"

5 ANTWORTEN 5
Nachricht 2 von 6
ToanDN
als Antwort auf: Marcus.Isacsson

You need to place and run the bat file from your top or root folder.
Nachricht 3 von 6
Marcus.Isacsson
als Antwort auf: ToanDN


@ToanDN wrote:
You need to place and run the bat file from your top or root folder.

Yes, that's what we're currently doing. But I wonder if anyone has a better way of cleaning the backup of families. Maybe another bat-script or plugin?

Nachricht 4 von 6

I have used a variant of the below previously, had it set to delete temp files older than one month:

 

:: --------DELOLD.BAT----------
@Anonymous off
SET OLDERTHAN=%1
IF NOT DEFINED OLDERTHAN GOTO SYNTAX

 

for /f "tokens=2" %%i in ('date /t') do set thedate=%%i

 

set dd=%thedate:~0,2%
set mm=%thedate:~3,2%
set yyyy=%thedate:~6,4%

 

echo Today: %dd%/%mm%/%yyyy% Remove files older than %OLDERTHAN% days

 

set /A dd=%dd% - %OLDERTHAN%
set /A mm=%mm% + 0

 

:CHECKDAY
if /I %dd% GTR 0 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1

 

:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
if %mm%==12 goto SET31

 

goto SYNTAX

 

:SET31
set /A dd=31 + %dd%
goto CHECKDAY

 

:SET30
set /A dd=30 + %dd%
goto CHECKDAY

 

:LEAPCHK
set /A tt=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29

 

:SET28
set /A dd=28 + %dd%
goto CHECKDAY

 

:SET29
set /A dd=29 + %dd%
goto CHECKDAY

 

:DONE
if /i %dd% LSS 10 set dd=0%dd%
if /I %mm% LSS 10 set mm=0%mm%

 

echo Deleting files created before %dd%/%mm%/%yyyy%

 

for %%i in (*.0???.rfa) do (
set FileName=%%i
call :PROCESSFILE %%~ti
)

 

set mm=
set yyyy=
set dd=
set thedate=
goto EXIT

 

:SYNTAX
ECHO.
ECHO USAGE:
ECHO DELOLD X
ECHO Where X is the number of days previous to Today.
ECHO.
ECHO EX: "DELOLD 5" Deletes files older than 5 days.
GOTO EXIT

 

:PROCESSFILE
set temp=%1
set fyyyy=%temp:~6%
set fdd=%temp:~0,2%
set fmm=%temp:~3,2%
:: ECHO %FileName% %fyyyy%/%fmm%/%fdd%
if /I %fyyyy% GTR 2069 set fyyyy=19%temp:~6%


:: +*************************************+
:: | This is where the files are deleted |
:: | Remove the 'rem' before DEL to |
:: | delete. ECHO is used for test. |
:: +*************************************+
if /I %yyyy%/%mm%/%dd% GEQ %fyyyy%/%fmm%/%fdd% (
ECHO %FileName% %fdd%/%fmm%/%fyyyy%
rem DEL %FileName%
)

 

set temp=
set fyyyy=
set fmm=
set fdd=

 

:EXIT

:: ----------END-DELOLD.BAT-------------

Nachricht 5 von 6

Impressive, thanks for sharing!
Does it also clean subfolders? That would be really neat. So that you don't have to copy and run the bat-files for each and every category of families in separate folders.

Nachricht 6 von 6

The variant we used did, the line that starts 'for %%i in (...' selects the files to be examined, that can be edited to look in sub-directories. look at the documentation for 'for' batch command. It can also be nested so we had it run first through all user directories on a PC looking for temp & local folders, then go through each of those folders looking for Revit temp files.

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report