此 Supybot for windows 批量安装脚本需要创建另一个批处理文件
Windows 批处理安装脚本的 Supybot 需要创建另一个批处理文件...
问题:
(1) 我有一个目录,其中有一个以 .conf 结尾的文件
(2) 只有一个文件在这个以 .conf 结尾的目录中
(3) 但我不知道这个文件以什么开头..我所知道的是 ?????????.conf
(4) 如何设置 filename.conf 和删除文件名的 .conf 部分?
(5) 因为它只是我需要的文件名的开头。
示例:
C:\runbot>查找“supybot.ident:”|输入 *.conf > temp.txt
robotsbot.conf
输出:robotbot.conf
任务是如何设置变量=robotbot
============================= ================================================
输入是这个名为“RootCode.conf”的文件以及许多其他文件 在搜索的目录中:
RootCode.conf
解决方案是:
FOR /F "tokens=1,2 delims=." %%a in ('FINDSTR /M "supybot.ident:" *.conf') DO SET USER=%%a&set dontneed=%%b
echo %USER%
Pause
输出是:
C:\runbot>FOR /F "tokens=1,2 delims=." %a in ('FINDSTR /M "supybot.ident:" *.con f') DO 设置用户=%a &设置 dontneed=%b
C:\runbot>SET USER=RootCode &设置 dontneed=conf
C:\runbot>echo RootCode 根代码
C:\runbot>pause 按任意键继续。 。 。
获胜者...特别感谢大家
This Supybot for windows batch install script needs to create another batch file...
The Problem:
(1) I have a directory that has a file that ends with .conf
(2) There is only one file in this directory that ends with .conf
(3) But I don't know what this file starts with.. all I know is ????????.conf
(4) How do I set the filename.conf and remove the .conf part of the file name?
(5) As it is just the beginning of the filename that I need.
Example:
C:\runbot>find "supybot.ident: " | type *.conf > temp.txt
robotbot.conf
Outputs : robotbot.conf
The quest, is how do I set a variable=robotbot
=========================================================================
The Input was this file named "RootCode.conf" among many others
within the directory searched:
RootCode.conf
The Solution is:
FOR /F "tokens=1,2 delims=." %%a in ('FINDSTR /M "supybot.ident:" *.conf') DO SET USER=%%a&set dontneed=%%b
echo %USER%
pause
The Output is:
C:\runbot>FOR /F "tokens=1,2 delims=." %a in ('FINDSTR /M "supybot.ident:" *.con
f') DO SET USER=%a & set dontneed=%b
C:\runbot>SET USER=RootCode & set dontneed=conf
C:\runbot>echo RootCode
RootCode
C:\runbot>pause
Press any key to continue . . .
Winner... Special thanks Everyone
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您将输出通过管道传输到
type
命令的示例要么是错误的,要么是无用的。因此,我假设您输入错误,并且实际行正在以相反的方式进行管道传输,因此我假设您正在尝试查找包含字符串“supybot.ident:”的文件的文件名。在这种情况下,我建议改用findstr
命令。有关详细信息,请参阅
HELP FINDSTR
、HELP SET
和HELP FOR
。Your example of piping the output to
type
command is either wrong or useless. So I am assuming you mistyped and the real line was piping the other way around, and thus I am assuming that you are trying to find the filename of the file that contains the string "supybot.ident: ". In that case I would suggest to usefindstr
command instead.See
HELP FINDSTR
,HELP SET
andHELP FOR
for more information.有点不清楚(至少对我来说)你在这里到底要问什么。但如果您需要命令的输出,请使用
for /f
:请注意,您需要在命令行中转义 shell 元字符(因为它们需要在一次解析过程中幸存下来)。另请注意,您不能将变量设置为包含多行文本。
It's a bit unclear (to me, at least) what exactly you ask here. But if you need the output of a command, then use
for /f
:Note that you need to escape shell metacharacters in the command line (as they need to survive one parsing pass). Also note that you cannot set a variable to contain more than one line of text.