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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:21:21+00:00 2026-05-26T11:21:21+00:00

Their input should be a directory in c:\folder\subfolder\ format. Additionally I don’t want it

  • 0

Their input should be a directory in c:\folder\subfolder\ format. Additionally I don’t want it to try to run unless the directory contains .flv files. So it needs to exist AND contain .flv files. Otherwise it should ask the user to input another directory.

The code also cleans up the slashes, and adds a trailing slash, which I need for other parts of the program. What I have works when given a directory that exists and contains the .flv files, but if it doesn’t contain .flv files it just ends the program instead of asking for additional input; meaning it porceeds as long as the directory exists, even if it doesn’t have any .flv files.

def is_valid_dir()
    input = "nil"
    until File.directory?(input) && Dir.glob("#{input}*.flv")
        puts "Enter the full directory path of the flv files."
        input = gets.chomp
        if input[-1..-1] == '/'
            # Do nothing if it already 
            # ends with a forward slash.
        else
            input += '/'
        end 
    end
    input.gsub!('\\', '/')
return input
end
  • 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-26T11:21:21+00:00Added an answer on May 26, 2026 at 11:21 am

    Dir.glob returns an empty array if there are no matches; check its length.

    Also, you say the input should be backslashy, but are checking for a forward slash. That aside, idiomatically you’re probably write that as:

    input += '/' unless input[-1..1] == '/'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When users input their images, their images are any size. I want to be
Im looking for ideas on how to effectively notify users that their input into
In my company, I've seen several approaches for notifying a user when their input
I have a simple webform that will allow unauthenticated users to input their information,
I have a bunch of input elements that have a particular substring in their
I have two input fields, and without changing their names (i.e., I have to
I'm trying to re-sort the child elements of the tag input by comparing their
I wrote several simulation programs in C++ and want to connect their outputs/inputs with
I'm having a system where users can input their purchased domain into their profile,
Basically, the input field is just a string. People input their phone number 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.