Hi, 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