移动名称中只有数字的文件的批处理文件

Batch file that move files with only digits in their names

我想要一个 windows 批处理代码,可以将名称中只有数字的文件从一个文件夹移动到另一个文件夹。我写了以下内容:

   FOR %%c in (C:\test1\*.*) DO MOVE %%c C:\test2 

这将移动所有文件,但我想移动名称中只有数字的文件(1123、12、12345 是名称中只有数字的所需文件的示例)

for %%c in (c:\test1\*.*) do ( echo %%~nc|findstr  "^[0-9]*$">nul && move "%%c" c:\test2 )

回显不带扩展名的文件名 (%%~nc),查找模式“<beginning><any digit><more of them><end>”,如果匹配 (&&) 则移动文件。

参考文献:for /?findstr /?

编辑:(回答您的评论)

感谢您的补充问题(感动"older than one day") 非常棘手,我从中学到了很多东西。

这将移动昨天或之前修改过的文件:

for /f "delims=" %%i in ('forfiles /d -1 /m * ^|findstr /R "^\"[0-9]*\"$" ') do echo move "c:\test1\%%i" C:\test2 

删除 echo

之前仔细测试