【问题标题】:Move only the first file [duplicate]仅移动第一个文件[重复]
【发布时间】:2020-01-17 12:05:30
【问题描述】:

如果文件夹中包含超过 100 个文件,我正在尝试构建一个移动第一个文件(按名称排序)的脚本。

我只能到这里,但它会移动所有文件。

有人可以帮帮我吗?

for /f %%a in ('dir /b /a-d C:\SOURCE ^|find /c /v ""') do set "remaining=%%a" 

forfiles /P C:\SOURCE /M * /C "cmd /c if @isdir==FALSE if %remaining% geq 100 
  move @FILE "C:\TARGET""

【问题讨论】:

    标签: batch-file cmd forfiles


    【解决方案1】:

    试试这个:

    @Echo Off
    For /F %%a In ('dir /b ^| sort') do set "first_file=%~fa" & goto break
    :break
    move "%first_file%" "C:\Target"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      • 1970-01-01
      • 2011-04-29
      • 2020-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多