查找批次变量的所有重复分钟 [英] Find all duplicate minutes variable for batch

查看:113
本文介绍了查找批次变量的所有重复分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,所以我有文件的文件夹,例如下面

Ok so i have a folder of files such as below

ERROR WITH Position Post_20162602_022046.eml
ERROR WITH Position Post_20162602_032048.eml
ERROR WITH Position Post_20162602_042050.eml
ERROR WITH Position Post_20162602_052108.eml
ERROR WITH Position Post_20162602_062109.eml
ERROR WITH Position Post_20162602_012110.eml
ERROR WITH Position Post_20162602_012111.eml
ERROR WITH Position Post_20162602_012114.eml
ERROR WITH Position Post_20162602_012121.eml
EXCEPTION ERROR_20162602_034502.eml
EXCEPTION ERROR_20162602_072602.eml
INCOMPLETE MESSAGE_20162602_092345.eml

我的目标是使用一个.bat文件来看看HH:MM:SS(小时:分钟:秒)
文件的一部分,并确定所有,在这个例子排在01 21电子邮件。然而,无功将取决于遇到错误,程序可能必须搜索不同的时间的时间改变...

My goal is to use a .bat file to look at the HH:MM:SS (hours:minutes:seconds) part of the file and to determine all the emails that came in at 01 21 in this example. However the var will change depending on the times that errors are encountered and the program might have to search for a different time...

在这个问题的唯一不变的是,该文件的时间将被复制,但我不知道有多少次,多长时间或多少的方式。所以我需要将.bat地看到,时间是重复的,然后告诉我所有被复制的文件。

The only constant in this problem is that the file times will be duplicated but i have no way of knowing how many times, how often or how much. so i need the .bat to see that the times are duplicated and then show me all the files that are duplicated.

我设法找到低于这个code,但它看起来的文件扩展名,具有恒定 PATTERN VAR

I managed to find this code below but it looks at the files extension and has a constant PATTERN var

@Echo OFF

Set "Pattern=abcd"

For /R "C:\" %%# in (*.xml) Do (
Echo %%~nx# | FIND "%Pattern%" 1>NUL && (
    Set /A "Index+=1"
    Call Set "XML%%INDEX%%=%%~#"
    Echo Full Path: %%~#
    REM Echo FileName : %%~nx#
    REM Echo Directory: %%~p#
)
)

CLS
Echo XML1 = %XML1%
Echo XML2 = %XML2%

Pause&Exit

我读了关于 QGREP 命令,但它需要一个不断的为好。据我所知。

I read up on the QGREP command but it needs a constant as well. As i understand it.

推荐答案

恐怕你的要求是混乱的,所以我改写的规格是这样的:

I am afraid your request is confusing, so I rephrased the specifications this way:

有几个文件与此文件名格式:

There are several files with this file name format:

Any text_YYYYDDMM_HHMMSS.eml

相应计数的文件HHMM和报告文件的名称当计数大于1

Count the files accordingly to HHMM and report the names of the files when the count is greater than 1.

@echo off
setlocal EnableDelayedExpansion

for %%a in (*.eml) do (
   for /F "tokens=3 delims=_" %%b in ("%%~Na") do (
      set "fileTime=%%b"
      for %%t in (!fileTime:~0^,4!) do (
         set /A "count[%%t]+=1"
         set names[%%t]=!names[%%t]! "%%a"
      )
   )
)

echo More than 1 message received at:
for /F "tokens=2,3 delims=[]=" %%a in ('set count[') do (
   if %%b gtr 1 (
      echo ------------------------
      for %%c in (!names[%%a]!) do (
         echo %%~c
      )
   )
)

输出例如:

More than 1 message received at:
------------------------
ERROR WITH Position Post_20162602_012110.eml
ERROR WITH Position Post_20162602_012111.eml
ERROR WITH Position Post_20162602_012114.eml
ERROR WITH Position Post_20162602_012121.eml

如果这不是你想要的,请在你的描述更加清晰。

If this is not what you want, please be clearer in your description.

这篇关于查找批次变量的所有重复分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆