I've got a batch file that copies some files based on user input and I want to simplify it. If a user types the letter A in the prompt, it copies A.txt from C:\ to E:\ Essentially, it goes like this:
set /p letter="Enter a letter of the alphabet"
if /i [%letter%]==[A] GOTO LetterA
if /i [%letter%]==[B] GOTO LetterB
if /i [%letter%]==[C] GOTO LetterC
:LetterA
robocopy C:\ E:\ A.txt
:LetterB
robocopy C:\ E:\ B.txt
:LetterC
robocopy C:\ E:\ C.txt
:end
Would I have to type out/copy each line for every letter of the alphabet, for both the IF statement and the goto command it calls? Can I accomplish this easier with a for loop or if statement and basically say..
For %letter%
robocopy C:\ E:\ %letter%.txt
Or like an IF statement, referring to a list.txt file.. whereas list.txt has all letters of alphabet in it..
IF %letter% in (C:\list.txt)
then robocopy C:\ E:\ %letter%.txt