Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:33:38+00:00 2026-05-31T17:33:38+00:00

I need a batch file that will search for the string Gen_1_X. When the

  • 0

I need a batch file that will search for the string “Gen_1_X”. When the string is found and lets say the “X” is a “4” the script will add “Gen_1_3” before and “Gen_1_5” before and after. Basically adding and subtracting one from the original number and adding the new entries before and after accordingly. The first block of code is what the end product should look like. The second block is what you have to work with.

<span class="O verse Gen_1_3" data-osis="Gen.1.3"><span class="verse-num v-4">4&nbsp;
<span class="O verse Gen_1_4" data-osis="Gen.1.4"><span class="verse-num v-4">4&nbsp;    </span></span>
<span class="O verse Gen_1_5" data-osis="Gen.1.5"><span class="verse-num v-4">4&nbsp;

<span class="O verse Gen_1_5" data-osis="Gen.1.5"><span class="verse-num v-5">5&nbsp;</span></span>
<span class="O verse Gen_1_6" data-osis="Gen.1.6"><span class="verse-num v-6">6&nbsp;</span></span>
<span class="O verse Gen_1_7" data-osis="Gen.1.7"><span class="verse-num v-7">7&nbsp;</span></span>
<span class="O verse Gen_1_8" data-osis="Gen.1.8"><span class="verse-num v-8">8&nbsp;</span></span>
<span class="O verse Gen_1_9" data-osis="Gen.1.9"><span class="verse-num v-9">9&nbsp;</span></span>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:33:39+00:00Added an answer on May 31, 2026 at 5:33 pm
    @echo off
    setlocal EnableDelayedExpansion
    call :processFile < inputFile.ext > outputFile.ext
    goto :EOF
    
    :processFile
       set line=EOF
       set /P line=
       if "!line!" == "EOF" goto :EOF
       set X=
       set "lineNoGen=!line:Gen_1_=$!"
       if "!lineNoGen!" neq "!line!" (
          for /F "tokens=1-3 delims=$" %%a in ("!lineNoGen:Gen.1.=$!") do (
             set "beforeGen=%%a"
             set "betweenGens=%%b"
             set "afterGen=%%c"
             set "X=!betweenGens:~0,1!"
             set /A Xm1=X-1, Xp1=X+1
             echo !beforeGen!Gen_1_!Xm1!!betweenGens:~1!Gen.1.!Xm1!!afterGen:~1!
          )
       )
       echo !line!
       if defined X (
          echo !beforeGen!Gen_1_!Xp1!!betweenGens:~1!Gen.1.!Xp1!!afterGen:~1!
       )
    goto :processFile
    

    Notes:

    1- Previous Batch file ends at the first empty line in the input file. This may be solved, if needed.

    2- There are certain restrictions in the input lines. Some may be solved, but some not. Please do a test and report the result.

    3- I suppose that input lines does not have $ characters. If so, change the $ in the Batch file by another unused character.

    EDIT: I fixed a small bug that does not update the number in Gen.1.X part.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a batch file that will recursively remove all directories with a certain
I need to either write a batch file or a vbscript that will rename
I need to create a batch file that reads a file with one line
I need to create a batch file that changes path to a particular folder
I need to create a batch file which will copy web log files from
I need to create a batch file that run MSBuild.exe I assumed that I
I have a batch file that needs to be passed a parameter that will
I'm trying to find a way with a batch file that will delete specific
I have a csv file that I will be regularly updating through a batch
I need to create an application that can be activated with a batch file.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.