I have multiple text (.cs) files that all have a line similar to this:
public partial class ApiIThis : IEquatable<ApiIThis>
or
public partial class ApiIThat : IEquatable<ApiIThat>
I need to transform them into
public partial class ApiIThis : IEquatable<ApiIThis>, IThis
public partial class ApiIThat : IEquatable<ApiIThat>, IThat
This will be run in a .bat
file that needs to run in a Windows command line
environment
Update: To answer @aschipfl
What have you tried so far, what do you have problems with? Please share your efforts by adding the information to the question!
What I have tried so far is doing some google searching to find some examples of what I'm trying to do. I found an SO post (How to replace substrings in windows batch file) that seems somewhat related, but it wasn't enough to get me going.
Anyway, do the .cs files only have lines like you showed, or even one only?
No, these will not be the only lines in the files. These files will have the full C#
class auto-generated by a Swagger
tool.
Do you need to find them between other lines, and if so, by what criteria?
Yes they will be between other lines. However, it will be the only line like this in the file. The file has the definition like:
using Something;
using SomethingElse;
public partial class ApiIThis : IEquatable<ApiIThis>
{
public ApiIThis()
{
/* Other code here */
}
/* Other code here */
}
Do the words after class and in between always match?
Yes, they will always match.
Could the words contain white-spaces?
No, they will never contain white-space.
Do you want to collect the transformed lines in a single output file, or do you want a separate output file per input file? or do you even want to overwrite/replace the original files?
I want the original file to be updated.
Finally I wanted to add that they will all start with Api
, actually ApiI