I'm attempting to write a basic batch file to help with some tasks at work. Current iteration is as follows:
'@echo off
echo 1: Follow-Up Email
echo 2: Things
echo 3: Stuff
set /p "option=Select Option:"
IF %option%==1(
type "C:\files\test.txt" | clip
)
ELSE IF %option%==2(
type "C:\files\test2.txt" | clip
)
ELSE IF %option%==3(
type "C:\files\test3.txt" | clip
)
ELSE (
echo Not a valid option.
) '
Situation: text.txt contains the string "text123." text2.txt contains the string "test2." etc. My problem is the script simply does nothing. No text is put to the clipboard. What simple thing(s) am I missing?
Thanks much in advance.
Your code formatting was fubar.
The spaces before the ( in the if tests were missing,
and the placement of ELSE must be on the same line as the ) and (
It's not as robust as it could be, but it works.
Your else if syntax is the problem. How about this?