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 9234521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:48:36+00:00 2026-06-18T06:48:36+00:00

I need a batch script to get the input from user and write it

  • 0

I need a batch script to get the input from user and write it to second column in a text file. Below is the one I tried, but it just create the incremental sequence of numbers, but I cant place them in the right place.

set /p rows: Enter number of rows:

for /l %%g in (1,1,%rows%) do echo %%g>> myfile.txt

myfile.txt is a comma separated file having 10 columns.

I want the incremental row numbers to come in second column.

  • 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-06-18T06:48:37+00:00Added an answer on June 18, 2026 at 6:48 am

    Assuming myfile.txt file looks something like this

    h,e,l,l,o,b,a,l,i,c
    

    Then this

    setlocal enabledelayedexpansion
    set /p num=Enter number of rows:
    set /a row=1
    for /f "tokens=1-10 delims=," %%a in (myfile.txt) do (
    echo %%a,!row!,%%b,%%c,%%d,%%e,%%f,%%g,%%h,%%i,%%j >>new.txt
    set /a row+=1
    if !row! gtr !num! goto :BREAK
    )
    :BREAK
    del myfile.txt /f /q
    ren new.txt myfile.txt
    

    Will output

    h,1,e,l,l,o,b,a,l,i,c  
    h,2,e,l,l,o,b,a,l,i,c
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to write batch script which copies file from FTP to local drive I'm
I need a script in batch file which will get me yesterdays date into
I need to send an email from a batch script. I tried several solutions
I need to create a batch file which will copy web log files from
I need to implement a function in a Windows batch script to get the
A simulation program I'm using requires a text based input file. I need to
I need to execute from Java a batch script, which does following 1) Once
I have a batch script that prompts a user for some input then outputs
Need a batch script to delete all records in a SQL Server CE database
I'm writing a batch (.bat) script and I need to handle the case in

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.