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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:46:10+00:00 2026-05-27T09:46:10+00:00

I have to show the filenames using given template. I’ve written the following code:

  • 0

I have to show the filenames using given template. I’ve written the following code:

if "%2" == ""  (
    echo "Missing second argument!"
    set /p FileName="Input file name template ('*', '?' are allowed): "
    set /p FileType="Input file type ('text', 'bat', 'all' only): "

    if FileType == "all" (set FileType = "*")
) else (
    set FileType="%2"
)


echo %DirSearch%\%FileName%.%FileType%

for %%i in (%DirSearch%\%FileName%.%FileType%) do  (echo "Thats it: %%i")

If the second argument is empty, I ask user about filename template, extension (if its equal to ‘all’ I rewrite it’s value as ‘*’.

Now the first trouble is that it isn’t rewritten. When I put ‘all’ the ‘FileType’ is still ‘all’ after setting it to ‘*’. Why?

And echo shows up:

"C:\Folder"\test.all
"Thats it: "C:\Folder"\test.all"

How to interpretate it as single value and use in for?


New code:

if "%2" == ""  (
        ...
    if "%FileType%" == "all" (set FileType=*)
) else (
        ...
)

set result=%DirSearch%\%FileName%.%FileType%
echo %result%

for %%i in (%result%) do  (echo "Thats it: %%i")


// echo %result%:
"C:\Data\test"\test.all
// in for cycle
"Thats it: "C:\Data\test"\test.all"

The right string should be: “C:\Data\test\test.all”

  • 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-27T09:46:11+00:00Added an answer on May 27, 2026 at 9:46 am

    You are not testing the value of FileType in the correct manner. Also, you are not setting the new value in the correct manner. The code should read

    if "%FileType%" == "all" (set FileType=*)
    

    Otherwise, you are just comparing the strings “FileType” and “all”, which of course never succeeds.

    Aside: You also seem to have some error in the code that sets DirSearch; there’s an extra trailing double quote there that shouldn’t be.

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

Sidebar

Related Questions

I have Divs show and hide (with an animation) using the following script (I
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I have written my code in -(void)loadView{ } to get an image from internet
I have the following code: SaveFileDialog saveGC1File = new SaveFileDialog(); private void GCSavePlacementOneButton_Click(object sender,
i have been trying the code using mutex but im unable to open my
Hi on our dev environment we have show all errors, warnings and notices. I'm
I have some text in a UITextView, that I would like to have show
I have a Show table, and I would like to have a derived type
I have to show a label with font size = 14 when the view
I have to show records in such a way that some selected records should

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.