Remove backup Revit files

Remove backup Revit files

jmvogt1986
Enthusiast Enthusiast
4,305 Views
8 Replies
Message 1 of 9

Remove backup Revit files

jmvogt1986
Enthusiast
Enthusiast

Greetings from South Africa!

I hope you're all well, I am an Autodesk Revit 2023 owner, I want to know how to delete my Revit backup files properly/cleanly.

A simple example is this screen shot 👇

 

jmvogt1986_0-1678636903256.png

I want to delete all the backup files (i.e file names that end with .0000)

 

All of my files are local and my computer's disks pace is limited and I don't want or need to have all of these backups saved onto my hard drive.

 

I also have dynamo and I want to learn how to use it. So could I use dynamo as well to delete all of my old Revit back up files.

 

Thank you in advance 🤘

 

 

0 Likes
Accepted solutions (1)
4,306 Views
8 Replies
Replies (8)
Message 2 of 9

RPTHOMAS108
Mentor
Mentor
Message 3 of 9

moturi.magati.george
Autodesk
Autodesk

Hi @jmvogt1986,

 

You can also follow the example below to delete the files in csharp:

https://bimmatters.wordpress.com/2016/03/26/595/

 

 

  Moturi George,     Developer Advocacy and Support,  ADN Open
Message 4 of 9

jmvogt1986
Enthusiast
Enthusiast

I see a lot of these examples are for family files does it also apply to model files?

0 Likes
Message 5 of 9

sayu94
Enthusiast
Enthusiast

Hello. I use this code, where f1.tbx1.Text - path to folder

 

FileInfo[] ListPathModelsToDelete;
FileInfo[] ListPathFamiliesToDelete;
FileInfo[] ListPathTemplatesToDelete;
if (f1.chbxDeleteCopy.Checked == true)
{
ListPathModelsToDelete = new DirectoryInfo(f1.tbx1.Text).GetFiles("*.rvt", SearchOption.AllDirectories);
ListPathFamiliesToDelete = new DirectoryInfo(f1.tbx1.Text).GetFiles("*.rfa", SearchOption.AllDirectories);
ListPathTemplatesToDelete = new DirectoryInfo(f1.tbx1.Text).GetFiles("*.rte", SearchOption.AllDirectories);
}
else
{
ListPathModelsToDelete = new DirectoryInfo(f1.tbx1.Text).GetFiles("*.rvt", SearchOption.TopDirectoryOnly);
ListPathFamiliesToDelete = new DirectoryInfo(f1.tbx1.Text).GetFiles("*.rfa", SearchOption.TopDirectoryOnly);
ListPathTemplatesToDelete = new DirectoryInfo(f1.tbx1.Text).GetFiles("*.rte", SearchOption.TopDirectoryOnly);
}
foreach (FileInfo fi in ListPathModelsToDelete)
{
string nameFile = fi.Name;
int i = 0;
bool delete = false;
while (i < 20)
{
string dop = "0";
if (i > 9)
{
dop = "";
}
if (nameFile.Contains("00" + Convert.ToString(i) + ".rvt"))
{
System.IO.File.Delete(fi.FullName);
delete = true;
}
i++;
}
}
foreach (FileInfo fi in ListPathFamiliesToDelete)
{
string nameFile = fi.Name;
int i = 0;
bool delete = false;
while (i < 20)
{
string dop = "0";
if (i > 9)
{
dop = "";
}
if (nameFile.Contains("00" + Convert.ToString(i) + ".rfa"))
{
System.IO.File.Delete(fi.FullName);
delete = true;
}
i++;
}
}
foreach (FileInfo fi in ListPathTemplatesToDelete)
{
string nameFile = fi.Name;
int i = 0;
bool delete = false;
while (i < 20)
{
string dop = "0";
if (i > 9)
{
dop = "";
}
if (nameFile.Contains("00" + Convert.ToString(i) + ".rte"))
{
System.IO.File.Delete(fi.FullName);
delete = true;
}
i++;
}
}
Message 6 of 9

jmvogt1986
Enthusiast
Enthusiast

Thank you, I'm not sure what this means though... Would you mind explaining how to use it? Thank you 💪

0 Likes
Message 7 of 9

sayu94
Enthusiast
Enthusiast
This code i use in my plugin, that work in families in folder and then it save family after work - it metod deletes reserve copies families files
0 Likes
Message 8 of 9

TripleM-Dev.net
Advisor
Advisor

Hi @jmvogt1986,

 

Looks like you don't use central models, so just save-as the model once with less backup files option set then Revit will clean up the older ones itself. I think they are set at 20st. at default, set it to 5st. or so, depending on you're own backup setups (time/location).

See this post: how-to-stop-revit-from-saving-autosave-files-to-the-original 

 

If you're using Code (dynamo etc) I would first check of a "backup named" file there's also a "regular named" Revit file of it, only delete the oldest backups and maybe keep a couple of them?

 

- Michel

Message 9 of 9

floretti
Advocate
Advocate
Accepted solution

I use a much simpler approach. Every once in a while I do a search on File Explorer for *.00??.rvt as this will bring up all the files ended in 00 plus two more numbers before the file extension starts. I then give the list a quick review just to make sure I'm not deleting a project file with a name that happens to match that pattern and simply hit delete.

 

Just keep in mind that backup files over the number 99 won't be captured in this method but you can easily adjust the search to suit and re-run it.

 

FileName.0001.rvt  [that will show up]

FileName.0045.rvt  [that will show up]

FileName.0099.rvt  [that will show up]

FileName.0100.rvt  [that will NOT show up]

 

I like doing that for Revit families as well as we always have the odd backup here and there in our libraries. Just remember to replace .rvt by .rfa and you're done. I hope that helps.