This is a modified recommendation based on David's answer.
sed is great, but I worry the proposed recipe is insufficiently cautious. Given the state of the source, do you really trust the author to have ensured the code is consistently formatted throughout the document? Perhaps that's true, but I think it is safer - at least when I'm the author - to assume fallibility.
s/{article}/{report}/
Fine. This is searching for an exact string and replacing it. On the other hand, it's probably only going to replace a single word in the document. So it's very low risk, but very low benefit.
s/\\section.{\\huge CHA.*\\\\ /\\chapter{/g
Are we sure we don't have something like
\section*{\huge CHAPTER 4. Another Thing
where the author forgot the line break? Or
\section {\huge CHAPTER 5. \ Yet Another
where the author missed the second backslash? If the script simply fails to find those things, that's not so bad. But
\section*{\huge CHAPTER 4. Another Thing\\And Another
will lose the first part of the title.
I'd try something more like
s/\\section\*{\\huge CHAPTER [0-9][0-9]*\. *\\\\ /\\chapter{/g
which is much more targeted.
However, what really motivated this answer is the third and fourth lines.
/\\addcontentsline.*CHAPTER/ d
/\\setcounter{section}{1}/ d
If the author is consistent, this is, of course, just what you want. But if not, you could potentially discard chunks of content unawares. You still have the original file1.tex, but I'd still err more on the side of caution.
Suppose the file contains
\section*{\huge CHAPTER 10.\\ Vital}\addcontentsline{toc}{section}{\numberline{}CHAPTER 10. Vital}
\setcounter{section}{10} This is an especially vital part of the text, so it's a shame this will get lost.
By this point, the first bit of mess is gone, so we have
\chapter{Vital}\addcontentsline{toc}{section}{\numberline{}CHAPTER 10. Vital}
\setcounter{section}{10} This is an especially vital part of the text, so it's a shame this will get lost.
These lines now become
i.e. nothing at all. Moreover, you might have something like
\addcontentsline{toc}{section}{\numberline{}CHAPTER 11.
Crucial}
\setcounter{section}{11}
which will become
Crucial}
and result in unbalanced text.
Instead, I'd recommend commenting these lines. This has the disadvantage of adding (hopefully unnecessary) clutter, but you can easily delete the lines wherever they become annoying, because you can just visually check it's safe. And if you never look at them to become annoyed, they will do no harm. On the other hand, it will be easier to figure out what's happened if something seems to be missing or you suddenly get weird errors.
/\\addcontentsline.*CHAPTER/s/^/%/
/\\setcounter{section}{1}/s/^/%/
Altogether,
s/{article}/{report}/
s/\\section\*{\\huge CHAPTER [0-9][0-9]*\. *\\\\ /\\chapter{/g
/\\addcontentsline.*CHAPTER/s/^/%/
/\\setcounter{section}{1}/s/^/%/
Especially if the document is fairly long, I'd prefer this because, however careful I am, I might not realise sed removed too much for some time and it is not always easy, at that point, to unpick what's happened. If the document is short, however, you can probably use David's version and just diff to check for anything untoward.
diff file1.tex file2.tex
For more context
diff -Naur file1.tex file2.tex
This latter invocation is often used to make patches and can be helpful if the changes don't make sense in isolation.
\chapter? And why the weird input syntax? – egreg Oct 05 '23 at 09:19\large, the word Chapter,\\\, and so on, as in the MWE. Giving the proper structure requires going through over 100 pages of text. – Przemysław Scherwentke Oct 05 '23 at 09:22\Section*{\huge CHAPTER 2. \\ Title}to work, right? – campa Oct 05 '23 at 09:27\Sectionso it has to have a*? – David Carlisle Oct 05 '23 at 09:29\section*{\huge CHAPTER 1.\\ Introduction} \addcontentsline{toc}{section}{\numberline{}CHAPTER 1. Introduction} \setcounter{section}{1}. I have changed the beginning as in MWE. – Przemysław Scherwentke Oct 05 '23 at 09:37regexmanual for beginners with application to TeX/LaTeX? – Przemysław Scherwentke Oct 05 '23 at 20:44