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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:31:26+00:00 2026-05-13T20:31:26+00:00

I asked a question here earlier today and got that fixed, but now I

  • 0

I asked a question here earlier today and got that fixed, but now I have another problem.. My batch file is supposed to take the user input of a directory and then save all of the names of the files within that directory to a user specified name text file. It also has the option to allow for you to include or not include subdirectories and Hidden/System files. My problem is that it only works right when the user decides to include both Hidden/System files and subdirectories, otherwise, it crashes.. Here is the code:

@echo off
:start
set /P DIRECTORY=Type Directory to Search: 
if not exist %DIRECTORY% goto :firstlogin
set /P FILENAME=Type the name for your output file:


:choice
set /P c=Include Sub-Directories?[y/n]?
if /I "%c%" EQU "Y" goto :somewhere
if /I "%c%" EQU "y" goto :somewhere
if /I "%c%" EQU "Yes" goto :somewhere
if /I "%c%" EQU "yes" goto :somewhere
if /I "%c%" EQU "YES" goto :somewhere
if /I "%c%" EQU "N" goto :somewhere_else
if /I "%c%" EQU "n" goto :somewhere_else
if /I "%c%" EQU "No" goto :somewhere_else
if /I "%c%" EQU "no" goto :somewhere_else
if /I "%c%" EQU "NO" goto :somewhere_else
goto :choice


:somewhere
set /P d=Include Hidden and System Files?[y/n]?
if /I "%d%" EQU "Y" goto :d1
if /I "%d%" EQU "y" goto :d1
if /I "%d%" EQU "Yes" goto :d1
if /I "%d%  EQU "yes" goto :d1
if /I "%d%" EQU "YES" goto :d1
if /I "%d%" EQU "N" goto :d2
if /I "%d%" EQU "n" goto :d2
if /I "%d%" EQU "No" goto :d2
if /I "%d%" EQU "no" goto :d2
if /I "%d%" EQU "NO" goto :d2
goto :somewhere

:d1
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait... 
Pause
dir /a /s /b /o  "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit


:d2
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait... 
Pause
dir /s /b /o  "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit



:somewhere_else
set /P e=Include Hidden and System Files?[y/n]?
if /I "%e%" EQU "Y" goto :e1
if /I "%e%" EQU "y" goto :e1
if /I "%e%" EQU "Yes" goto :e1
if /I "%e%" EQU "yes" goto :e1
if /I "%e%" EQU "YES" goto :e1
if /I "%e%" EQU "N" goto :e2
if /I "%e%" EQU "n" goto :e2
if /I "%e%" EQU "No" goto :e2
if /I "%e%" EQU "no" goto :e2
if /I "%e%" EQU "NO" goto :e2
goto :somewhere_else


e1:
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait... 
Pause
dir /a /b /o  "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit


e2:
echo The Program Will Exit When Operations are Completed....
Pause
echo Working Please Wait... 
Pause
dir /b /o "%DIRECTORY%" > C:\Users\Zack\Desktop\%FILENAME%.txt
exit


:firstlogin
echo Directory does not exist!
Pause
goto :start


:done
SET stg=
SET /P stg=Start again?[y/n]? 
cls
IF %stg% == Y goto :START
IF %stg% == y goto :START
IF %stg% == yes goto :START
IF %stg% == Yes goto :START
IF %stg% == YES goto :START
  • 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-13T20:31:26+00:00Added an answer on May 13, 2026 at 8:31 pm

    It’s a simple typo:

    e1: 
    echo The Program Will Exit When Operations are Completed.... 
    

    should be:

    :e1
    echo The Program Will Exit When Operations are Completed.... 
    

    Same for e2:, should be :e2.

    Pay attention to the error messages…

    Edit:

    About your comment, check:

    :somewhere 
    set /P d=Include Hidden and System Files?[y/n]? 
    if /I "%d%" EQU "Y" goto :d1 
    if /I "%d%" EQU "y" goto :d1 
    if /I "%d%" EQU "Yes" goto :d1 
    if /I "%d%  EQU "yes" goto :d1 
    

    The last line is missing a " after "%d.

    It’s very easy to debug things like this. Just change echo off to echo on at the beginning and you’ll see which was the last executed line and the error message.

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

Sidebar

Related Questions

I earlier asked another question here However, I later realized that my requirements are
I have asked this question earlier today but I didn't provide enough information and
I asked a question earlier today here . However, what I neglected to check
Related to a question I asked earlier here , I've found a problem which
I asked this goofy question earlier today and got good answers. I think what
Alright. So I asked a question here but I feared that I anwsered it
I asked a question earlier today, but I think I need to approach it
I know that this question was asked earlier but the OP didn't get any
I asked this question earlier but I didn't express myself correctly. If I have
I know that this question might have been asked like 100 times, but, believe

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.