首页 > 解决方案 > 复制Windows cmd中按条件选择的多个文件

问题描述

我正在尝试将所有具有 2 位数字格式的文件(例如 12.txt、15.pdf、25.doc... 等)从一个目录复制到另一个目录,这是在 Windows 中。

在 Linux 中这有效:

cp -t target_directory {10..99}.*

在 Windows 中,解决方案是什么?

标签: windowsbatch-file

解决方案


This is ugly but should work

for /L %i in (10,1,99) do @copy %i.* dest_folder_here >nul 2>&1

It tries every file in the range suppressing conditions. Adjust copy to overwrite if needed.


推荐阅读