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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:12:44+00:00 2026-06-13T04:12:44+00:00

Hello I’m trying to complete a batchfile im working on. I have a library

  • 0

Hello I’m trying to complete a batchfile im working on.

I have a library of motivational quotes textfiles, and i want my batchfile to pick one random quote textfile and display it in the command window. with the command type i guess.

my path to the folder with the quotes is:

 C:\Users\niv\Documents\test\scripts\quotes

inside there is :

      Quote 1.txt
      Quote 2.txt
      Quote 3.txt.

i did the command: `type “C:\Users\niv\Documents\test\scripts\quotes\quote1.txt”
that only displayed the selected quote1.txt ofcourse.

If possible i want to get the selected Quote-text file to be a variable so i can use it for different tasks in my batchfile like:

after receiving the selected quote do this command with a program that makes it possible for my computer to read anything after “”. like this

%speech% "%quotes%"

the %speech% lets my computer speak whats inside the quotation marks.

i hope you can understand what im trying to accomplish here if not just ask 🙂

  • 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-13T04:12:45+00:00Added an answer on June 13, 2026 at 4:12 am

    I am assuming each quote is contained in a single line in each file. I recommend placing all the quotes in a single file named quotes.txt, with one quote per line. This should make it easier to maintain the quotes. Then all you need is code that will count the number of lines in the file, and then randomly pick a line between 1 and count.

    The FIND /C command can count the number of lines in a file.

    The %RANDOM% dynamic variable gives a pseudo random number between 0 and 32767, and the modulo SET /A operator can be used to convert the value into a number between 0 and count-1.

    The FOR /F command reads lines from a file, and you can use the SKIP option to skip a random number of lines.

    quotes.txt

    quote 1
    quote 2
    quote 3
    quote 4
    

    randomQuote.bat

    @echo off
    setlocal
    
    :: Count the number of quotes and define a random number to skip
    for /f %%N in ('find /c /v "" ^<quotes.txt') do set /a skip=%random% %% %%N
    if %skip% gtr 0 (set skip=skip=%skip%) else set "skip="
    
    :: Read a random quote into a variable
    for /f "%skip% delims=" %%A in (quotes.txt) do (
      set "quote=%%A"
      goto :break
    )
    :break
    
    :: Echo the quote (or do whatever you need)
    echo %quote%
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all I am working on javascript jquery and svg.I want to ask a
hello all i am working on a project in which i have a webpage
Hello I want to get Accurate location so that i have used following link
hello friends i am trying to get a list of user id and want
Hello ever one I want to ask a question about file opening.I want to
Hello i been trying to get a tokenizer to work using the boost library
Hello The following procedure will have to move all constraints from one table to
Hello guys I am working on silverlight and I have issue regarding on database
Hello, I want to put custom status bar in notification window of iphone. is
Hello all I am working on html and javascript.And I am going to ask

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.