Download

VS Filters backup and restore

Hi ,

Short version :
I wanted to share this little utility that backs up and restore your filters you made for your C++ files in visual studio, this will help to make sure you don’t lose filter when your regenerate VS Project files or anything. Just remember to make backups in time :wink: Get the Files from attachment

**What is it? **
Its a pair of bat files ,one for backup and one for restore . Backup copies filters file from intermediate to project root directory and hides it. Restore copies it back from project root directory to intermediate and unhides it. TADAA!

How to use?
Put the two .bat files in same directory as your .uproject file (root project folder) then Just run BackupFilter.bat when you want to backup your filters and whenever your filters mess up for some reason just run RestoreFilter.bat , reload VS project or restart VS and filters will be back.

Whats the catch?
Not tested with VS 2013 or custom source built UE4. It deduces project name from .sln file.

Long Version

What is this?

Most programmers like to group the code files in certain folders to make work organised, like you’ll want to keep all character related code in a folder called character and car related code in a folder named vehicles. In visual studio there is a very useful option that allows you to do so by creating filters by just right clicking on solution explorer.

Filters are saved in \Intermediate\ProjectFiles<project name>.vcxproj.filters

However if for some reason the project file changes , like you right click .uproject file and select generate visual studio project files or something similar, then the filters are lost.

So these bat files simply run some old dos commands in shell that copies the vcxproj.filters file to your projects root directory and renames it .vcxproj.filters.backup , then it sets it hidden so you don’t get bothered by seeing lot of files :stuck_out_tongue: . (you can edit the bat to remove the hiding part)

When restoring the bat file copies the .vcxproj.filters.backup restored previously back to \Intermediate\ProjectFiles\ and removes the .backup part from the extension.

You’ll need to reload the project in Visual studio or restart visual studio for the changes to take effect.

**
But why don’t you use folders?**

UBT doesn’t care about VS project so you need to make folders manually in windows explorer which is cumbersome. The biggest drawback is you have to respect and mention folder path when including files.

So if you put ball.h in physics folder and player.h in characters folder then to use ball.h in player class you’ll have to do #include "…/physics/ball.h"

now if you want to move ball.h to items folder for some reason you’ll have to edit all the files that use #include “…/physics/ball.h” to #include"…/items/ball.h"

when you have literally dozens of files this can become nightmare, but with Filters you don’t need to include filter names, with filters #include “ball.h” will work fine no matter what filter ball is in.

It seems that isn’t working to me. Unfortunately, I barely understand .BAT files in order to fix them — DOS commands are not my best skill. Regardless I let or not BackupFilter.bat hides the copied files, nothing appears at root folder after running it. Furthermore, despite the fact that I comment the “echo off” command, when running the .BAT files they show nothing on the prompt — moreover, the prompt just blinks and disappears on a wink.

So I came across this post while trying to find a simple solution to this problem and it’s a great idea. Problem is that it’s outdated with windows 10.

So here’s an updated version which works.

Run BackupFilter.bat either from the command line or just double clicking on it.

The backup file will go to the same directory.

Run RestoreFilter.bat.

The backup file will be copied back over. If you want to delete the backup file right click on the restore batch file and click edit. Then remove the preceding colons from the last line.