【问题标题】:Count files and then copy files if there are files missing计数文件,如果有文件丢失,则复制文件
【发布时间】:2014-02-13 20:02:36
【问题描述】:

我需要设置一个批处理来查看文件夹以查看它是否包含所需的所有文件。如果找不到文件的数量,则复制​​它们。

所以我的伪代码应该是这样的。

If c:\folder filecount NOT 1000 files then copy \\\server\source\\*.* c:\folder

我该怎么做?

【问题讨论】:

    标签: file batch-file count copy


    【解决方案1】:

    应该这样做

    @echo off
    setlocal
    
    for /f "tokens=1" %%a in ('dir c:\path ^|find "File(s)"') do (
        if %%a NEQ 1000 xcopy "\\server\source\*.*" "c:\folder"
    )
    

    【讨论】:

      【解决方案2】:
      for /f %%a in ('dir /a-d /b ^|find /c /v ""') do if not "%%~a"=="1000" xcopy "\\server\source\*.*" "c:\folder"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-14
        • 1970-01-01
        • 2014-01-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多