shell - 用于移动列表中指定文件的批处理命令

标签 shell batch-file

我需要从 Windows 控制台移动一组文件。选择要移动的文件的标准是基于内容:

findstr /M "<content-criteria>" *.$$$ > files_to_move.txt

如何启动 move 命令来处理此列表?

我完全错误的尝试:

move %1 dest_folder < files_to_move.txt

最佳答案

您需要对列表中的每个文件执行移动操作

for /f "delims=" %%a in (files_to_move.txt) do move "%%a" dest_folder

for/f 命令将读取输入文件。对于每一行,do 子句之后的代码将使用存储在可替换参数 %%a 中的该行内容来执行。 "delims=" 子句向 for 命令指示,不会使用分隔符来分割标记中的行。

关于shell - 用于移动列表中指定文件的批处理命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25605668/

相关文章:

file - 选择多个文件, "send to"batch.cmd,让batch.cmd对选定的文件运行一个程序

linux - shell 脚本。分割线

bash - 如何等待消息出现在登录 shell 中

Python ssh paramiko 检测失败的命令

bash - 如何在 shell 中为 graphicsmagick 编写循环?

android - Bluestacks (HD-StartLauncher.exe) 通过命令提示符打开

batch-file - 使用参数从包含的批处理文件中调用函数

linux - Xinetd 禁用标准错误重定向

node.js - 使用 cxsd 将 .xsd 转换为 TypeScript,cxsd 无法识别

linux - 使用批处理脚本从Windows检查Linux服务器中的服务