此 Supybot for windows 批量安装脚本需要创建另一个批处理文件

发布于 2024-10-29 06:47:02 字数 1127 浏览 6 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

停顿的约定 2024-11-05 06:47:02

您将输出通过管道传输到 type 命令的示例要么是错误的,要么是无用的。因此,我假设您输入错误,并且实际行正在以相反的方式进行管道传输,因此我假设您正在尝试查找包含字符串“supybot.ident:”的文件的文件名。在这种情况下,我建议改用 findstr 命令。

FOR /F "tokens=*" %%a in ('FINDSTR /M "supybot.ident:" *.conf') DO SET USER=%%a

有关详细信息,请参阅HELP FINDSTRHELP SETHELP FOR

Your example of piping the output to typecommand 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 use findstr command instead.

FOR /F "tokens=*" %%a in ('FINDSTR /M "supybot.ident:" *.conf') DO SET USER=%%a

See HELP FINDSTR, HELP SET and HELP FOR for more information.

行至春深 2024-11-05 06:47:02

有点不清楚(至少对我来说)你在这里到底要问什么。但如果您需要命令的输出,请使用 for /f

for /f "delims=" %%x in ('some command ^| line') do set somevar=%%x

请注意,您需要在命令行中转义 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:

for /f "delims=" %%x in ('some command ^| line') do set somevar=%%x

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文