I have a .txt document with over 32,000 lines of commented machine code. It looks like this:
Display menu window
C0/000E:    E220        SEP #$20       (Set 8-bit accumulator)
C0/0010:    C210        JSR $0011      (Call function X)
I need to convert it as follows:
Display menu window
C0/000E:    E220        SEP #$20       (Set 8-bit accumulator)
C0/0010:    C210        JSR C00011     (Call function X)
Specifically, that means the script must:
- Skip blank lines
 - Skip lines that don't start with "C0/"
 - Check if "JSR $" is the 25th character on the line. (Assuming my counting is right)
 - Replace "JSR $" with "JSR C0" (preferably, replace "$" with "C0")
 - Remove a space after "JSR C0XXXX" to keep the comments aligned, as we just added a character to the line ($ -> C3).
 
I have this code that I've been trying to edit to achieve this. You can fix it or write your own.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET source=%1
FOR /F "tokens=1 delims=." %%t IN ("%source%") DO SET target=%%t
SET target=!target!_2.txt
TYPE NUL>!target!
FOR /F "tokens=1* delims=]" %%j in ('type "%source%" ^| find /V /N ""') DO (
    IF "%%k"=="" (
        ECHO.>>!target!
    ) ELSE (
        SET currentLine=%%k
        IF "!currentLine:~0,3!"=="C0/" (
            IF "!currentLine:~25,5"=="JSR $" (
                SET left=!currentLine:~0,24!
                SET right=!currentLine:~25!
                ECHO !right!
                SET right=!right:(=C0!
                SET right=!right:^)=!
                ECHO !right!
                SET currentLine=!left!!right!
            )
        )
        ECHO !currentline!>>!target!
    )
)