I have a set of variables that represent directory names: folder_1
, folder_2
,... folder_n
.
In my code I am trying to set the variable FOLDER
to the correct directory name based on the user input selection after validating the value with a conditional if
statement. However, as my code is, the FOLDER
variable is assigned with double quote which causes the DESTINATION
variable to end up looking something like this: C:\User\stackoverflow\"chosen folder"
When attempting to use this variable as the destination for a move
command it fails.
@echo off
setlocal EnableDelayedExpansion
REM totally nothing import happening up here
set /p selection=""
if %selection% GEQ 0 if %selection% LEQ %a% (
echo you selected folder !folder_%selection%!
set FOLDER="!folder_%selection%!"
set DESTINATION=!PATH!\Bermuda Triangle\!FOLDER!
set /a pass=1
)
REM nothing here either
move /-y C:\wherever\this\file\is DESTINATION
pause
Okay, that's fine, I'll just lose the quotes in line 10
.
set FOLDER=!folder_%selection%!
Running my script with these changes "apparently" fixes the syntax issue for the move command, because it gets moved to where it is supposed to; however, the pause command at the end of my script no longer works and the window closes. So while it works I can't check my echo feedback calls to make sure everything is functioning as intended.
Can anyone help me understand what is going on here?