A
A
Adwardvaleev2021-06-21 14:49:17
cmd/bat
Adwardvaleev, 2021-06-21 14:49:17

How to merge all project files into one?

There is a project located, say, on c:/bh/front
Inside - a bunch of subfolders and files

We need a script that will recursively go through all subfolders, take the contents of each file (for example, by *.php, *.vue, *.js mask ) and will drive it into one output file, let's say c:/bh/froutoutput.txt

well, and so that there is no porridge at all - preferably before each piece of code - so that the file name is written.
Something like this:

froutoutput.txt:

Файл: c:\bh\front\components\Addresses.vue

<тут содержимое файла Addresses.vue> 


Файл: c:\bh\front\components\catalog\CatalogBody.vue

<тут содержимое файла CatalogBody.vue>


I searched the Internet, as always, there are many solutions, but it's not that.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
ComodoHacker, 2021-06-21
@ComodoHacker

The simplest option:

set SOURCEDIR=c:/bh/front
set OUTPUT=c:/bh/froutoutput.txt

pushd %SOURCEDIR$
for /r %F in (*.php) do (
    echo ================= >> %OUTPUT%
    echo Файл: %~fF >> %OUTPUT%
    type %~fF >> %OUTPUT%
)
popd

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question