标题: [文件操作] [已解决]求助批处理怎样把多条命令的返回结果输出到文本不换行? [打印本页]
作者: habulu 时间: 2015-3-1 00:19 标题: [已解决]求助批处理怎样把多条命令的返回结果输出到文本不换行?
本帖最后由 pcl_test 于 2017-3-31 17:42 编辑
比如这两个命令(命令可能不同)- wmic datafile where "drive='c:' and path='\\Windows\\' and filename='notepad'" get filename,size | find "notepad" >c:\1.txt
- wmic datafile where "drive='c:' and path='\\Windows\\' and filename='notepad'" get filename,size | find "notepad" >>c:\1.txt
复制代码
想让他们不换行,用下面的命令,可是没输出- @echo off
- for /f "tokens=*" %%i in ('wmic datafile where "drive='c:' and path='\\Windows\\' and filename='notepad'" get filename,size | find "notepad"') do ((set/p="%%i"<nul)>>"c:\1.txt")
- pause
复制代码
请教有没什么办法让多条命令的输出不换行
作者: pcl_test 时间: 2015-3-1 11:30
回复 1# habulu
两个例子参考下- @echo off
- for /f "delims=" %%i in ('echo 125 ^&^& ver ^&^& echo 345') do set /p=%%i<nul
- pause
复制代码
- @echo off
- setlocal enabledelayedexpansion
- set s=
- for /f "tokens=1-2" %%i in ('wmic datafile where "drive='c:' and path='\\Windows\\' and filename='notepad'" get filename^,size ^| find "notepad" ^&^& wmic datafile where "drive='c:' and path='\\Windows\\' and filename='regedit'" get filename^,size ^| find "regedit"') do set "s=!s!%%i %%j "
- >1.txt echo !s!
- pause
复制代码
作者: habulu 时间: 2015-3-1 20:59
可以了 非常感谢
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |