批处理文件 - 复制文本文件的内容到剪贴板 [英] Batch File - Copying contents of text file to clipboard
本文介绍了批处理文件 - 复制文本文件的内容到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图编写一个基本的批处理文件,以帮助在工作中的一些任务。当前迭代如下:
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.
) '
现状:的text.txt包含字符串text123。 text2.txt包含字符串test2的。等我的问题是剧本根本什么都不做。没有文本放置到剪贴板。有什么简单的事情(S)我缺少什么?
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?
感谢很多提前。
推荐答案
您否则,如果语法有问题。这个怎么样?
Your else if syntax is the problem. How about this?
@echo off
:Start
cls
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 & goto :Done
IF "%option%"=="2" type "C:\files\test2.txt" | clip & goto :Done
IF "%option%"=="3" type "C:\files\test3.txt" | clip & goto :Done
echo.Not a valid option.
pause
goto :Start
:Done
这篇关于批处理文件 - 复制文本文件的内容到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文