Friday, March 31, 2017

move all .cpp & .h in a filter to another project AND correct their folder location

Leave a Comment

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

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

(In real case, all filters contains a lot of sub-sub-filter and files.)

Question

How to :

  • move all .h and .cpp files (B and C) inside myFilter02 to ProjectName2's folder (e.g. D:\ProjectName2)
  • don't change appearance of the filter (e.g. C must be still in subFilter2_1\subFilter2_2)
  • and do it in a few clicks (i.e. not depend on amount of files/sub-filters) i.e. O(1)

Here is the expected result :-

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

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

I tried to right click the filter/files, but didn't found such feature.
I currently don't use any Microsoft's source control / repository (just in case it is related).

Note: The normal drag & drop on filters don't move the files to another project's folder.
It just makes the moved files to be a shortcut of the original location (D:\ProjectName1\).

Hotkey? Plugin? Script?
Do I really have to create a program to do this specific thing?

A few days after asking, I have coded it with c++ using RapidXML ~ 500-1000 lines.
I have to edit .vcxproj.filters and .vcxproj of both projects, and move some system files.
I still find no answer about the question, though.

Edit

(After receive advise from Hans Passant and Prab, thank!)
I want to use filter rather than folder for these reasons :-

  • Source control is easier, because all source files are in a same directory.
  • In Visual Studio, I can move files around different filters a little easier than around folders.
  • With Filter, I don't have to lengthen #include "../myFilter01/K.h" or add additional include directories for each folder. I can simple #include "K.h".
  • If I change the place where a file resides in a filter, I don't have to refactor it.
    In case of changing folder, I have to refactor code.
  • I can use very strange character e.g. =◆██myFilter01██◆= for filters but not folder. It is my taste.

I don't want to

  • Use folder instead of filter : Beside difficulty of recreate many folders and move my .cpp/.h files manually, I will suffer the above disadvantages.
  • Use folder with same structure as filter : I have to keep it in sync together manually (all the time - tedious). I will still get some the above disadvantages.

In summary, using folder instead of filter causes me more new trouble than it solves.

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment