windows - 批量发送输出到 nul 不起作用

标签 windows batch-file text windows-7 cmd

当我运行此代码时,如果没有 Num.txt,它会说找不到该文件。我如何阻止它说我已经尝试过 >nul 但它似乎没有任何区别。

@echo off
for /f "delims=" %%x in (Num.txt) do set "d=%%x">nul
echo %d% & pause

有谁知道哪里出了问题吗?

最佳答案

我添加了第二行并删除了 >nul

@echo off
if not exist num.txt goto :EOF
for /f "delims=" %%x in (Num.txt) do set "d=%%x"
echo %d% & pause

关于windows - 批量发送输出到 nul 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22534553/

相关文章:

c++ - 在 C++ 中线程化 for 循环

postgresql - 使用 Qt 安装程序安装后无法运行 .bat 文件

macos - bash - 从文本文件中删除多行不同的文本

c++ - 用于编辑文本的最小 CPU 和内存开销数据结构?

windows - 使用批处理文件计数文件

使用 Linux 命令的 Python 脚本不能在 Windows 上运行。有什么办法让它与操作系统无关吗?

c++ - 使用免注册 COM 时 Powershell 无法使用 COM 对象

windows - 批处理脚本 : Why doesn't redirecting stdout work in this scenario?

javascript - 如何将批处理代码与vbscript代码合并

linux - 在 Linux 中排列文本