batch-file - write a batch output in a certain position on a text file, on a single line
问题描述
i would like to have the output from a batch routine (for example a dir comand) on a .txt file, then read it and take one line a the time and insert it inside a string on a .vbs file. The vbs file must send some comands to another batch so it requires that the text inside the string fits on a single line. I can't manage to insert the text, neither to fit it in one line.
the code goes something like this:
dir /s /b >> text.txt
for /f "tokens=*" %%i in(text.txt) do (echo %%i > comands.vbs)
@echo OBJECT.SendKeys ^" +()+.{ENTER} ^" > comands.vbs
pause
I need the output of dir /s /b to be read and insert it where the +()+ is.
解决方案
You can use the FOR
variable and insert that into the echo command. I think this is what you want to do but maybe I am over simplifying it.
@echo off
(for /F "delims=" %%G in ('dir /b /s') do (
echo OBJECT.SendKeys "%%G {ENTER}"
)
)>commands.vbs
pause
推荐阅读
- security - 如何使用 Micronaut Security 将未经授权的 WWW-Authenticate 字段添加到响应标头?
- javascript - 无法使用“cookies.set”存储 cookie
- apache-spark - 是对已经分区宽还是窄的数据进行分组转换?
- lisp - 如何从 LISP 中的列表中删除 nil 值?
- javascript - Discord.js - 如果单独在队列末尾,机器人不会离开频道
- typescript - 如果我想从带有 `vue-property-decorator`(类风格)的 vue2 升级到 vue3,有什么需要担心的吗?
- android - ffmpeg 无缝播放 webm 片段
- python - 将子标题添加到熊猫数据框
- javascript - 始终重定向到当前路线而不是所需路线
- for-loop - 使用 PLSQL,如何使用列名的变量访问选择循环中的列?