Move all .cpp & .h to the filter in another project And correct the location of your folder

Here is the filter of my project in Visual Studio shown in Solution Explorer : -

ProjectName1 == References, External Dependencies, Header Files, Resource Files == Source Files ==== myFilter01 ------ Kh (system folder = `D:\ProjectName1\Kh`) ------ K.cpp (system folder = `D:\ProjectName1\K.cpp`) ==== myFilter02 ====== subFilter2_1 --------- Bh (system folder = `D:\ProjectName1\Bh`) --------- B.cpp (system folder = `D:\ProjectName1\B.cpp`) ========= subFilter2_2 ----------- Ch (system folder = `D:\ProjectName1\Ch`) ----------- C.cpp (system folder = `D:\ProjectName1\C.cpp`) ProjectName2 == ... (some existing filter/files) 

(In the real case, all filters contain many sub-filters and files.)

Question

How to do:

  • move all .h and .cpp files ( B and C ) inside myFilter02 to the ProjectName2 folder (for example, D:\ProjectName2 )
  • does not change the appearance of the filter (e.g. C must remain in subFilter2_1\subFilter2_2 )
  • and do it in a few clicks (i.e. it does not depend on the number of files / subfilters), i.e. O(1)

Here is the expected result: -

 ProjectName1 == References, External Dependencies, Header Files, Resource Files == Source Files ==== myFilter01 ------ Kh (system folder = `D:\ProjectName1\Kh` ) ------ K.cpp (system folder = `D:\ProjectName1\K.cpp` ) ==== myFilter02 ProjectName2 == ... (some existing filter/files) == subFilter2_1 ----- Bh (system folder = `D:\ProjectName2\Bh` ) ----- B.cpp (system folder = `D:\ProjectName2\B.cpp` ) ===== subFilter2_2 ------- Ch (system folder = `D:\ProjectName2\Ch` ) ------- C.cpp (system folder = `D:\ProjectName2\C.cpp` ) 

This can be done manually for each sub-sub-filter + add existing files, but it is very tiring.

I tried right-clicking the filter / files, but did not find such a function.
I currently do not use any Microsoft source / storage (just in case this is related).

Note. Normal drag-and-drop on filters does not transfer files to another folder .
It just makes the moved files be a shortcut to the original location ( D:\ProjectName1\ ).

Hotkey? Plugin? Script?
Do I need to create a program to perform this specific task?

A few days after the request, I encoded it using C ++ using RapidXML ~ 500-1000 lines.
I need to edit .vcxproj.filters and .vcxproj both projects and move some system files.
I still cannot find the answer to this question.

Edit

(After receiving advice from Hans Passan and Prab, thanks!)
I want to use a filter rather than a folder for the following reasons: -

  • Source control is easier because all source files are in the same directory.
  • In Visual Studio, I can move files around various filters a little easier than around folders .
  • With the filter, I do not need to extend #include "../myFilter01/Kh" or add additional directories for each folder. I can just #include "Kh" .
  • If I change the location of the file in the filter , I do not need to reorganize it.
    In case of changing the folder , I have to use the refactoring code.
  • I can use a very strange character, for example. =β—†β–ˆβ–ˆmyFilter01β–ˆβ–ˆβ—†= for filters, but not for the folder. This is my taste.

I do not want

  • Use a folder instead of a filter: In addition to the difficulties of creating many folders and manually moving my .cpp/.h files, I will experience the above disadvantages.
  • Use a folder with the same structure as the filter: I need to synchronize it manually (tedious all the time). I still get some of the above disadvantages.

In general, using a folder instead of a filter causes me more new problems than it solves.

+8
c ++ visual-studio
source share
1 answer

This is not one click solution, but it can be done faster than manually.

  • Find out which file you want to copy. To do this, move the filters from one project to another. Then switch to viewing the directory (show all files) for the first project and copy, but not past files with a small red indicator (files that are not included in the project). Now back to the film, both for the project and for moving back to the first project. After that, switch both projects to catalog view mode and transfer the second project.

  • Now we need to create the right filters. Move files from the source and header filters to other filters in the second project. Unload both projects. Open the first and second .filters project files, copy them from the first file to the second filter tag, except for "Source files", "Header files", "Resource files". Next, from the second file, remove all tags starting with the source or header. Now from the second ItemGroup, copy all the content and transfer it to the second file of the second ItemGroup. Save the second file.

  • At this point, you should have a copy of the first project filter tree without unnecessary files, now just move what you want to fix.

In the first project, it is useful to create a single tree.

0
source share

All Articles