我有一個日誌文件Source.txt
與以下內容結構:升壓了批處理速度
Handle v3.51
Copyright (C) 1997-2013 Mark Russinovich
Sysinternals - www.sysinternals.com
------------------------------------------------------------------------------
DataSource.exe pid: 5860 USER\DEVELOPMENT
5EC: File (R--) G:\apps\OracleClient\product\11.1.0\client_2\RDBMS\mesg\ocius.msb
600: File (R--) G:\apps\OracleClient\product\11.1.0\client_2\RDBMS\mesg\ocius.msb
614: File (R--) G:\apps\OracleClient\product\11.1.0\client_2\RDBMS\mesg\ocius.msb
628: File (R--) G:\apps\OracleClient\product\11.1.0\client_2\RDBMS\mesg\ocius.msb
834: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP1_RulesLogFiles\1-28-2014_Timer.log
838: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP1_RulesLogFiles\1-28-2014_Debug.log
854: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP1_RulesLogFiles\1-28-2014_Timer.log
858: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP1_RulesLogFiles\1-28-2014_Debug.log
874: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP1_RulesLogFiles\1-28-2014_Timer.log
878: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP1_RulesLogFiles\1-28-2014_Debug.log
1058: File (RW-) C:\Windows\winsxs\amd64_microsoft.vc80.atl_1fc8b3b9a1e18e3b_8.0.50727.4053_none_8a1a02152edb659b
------------------------------------------------------------------------------
DataSource.exe pid: 10568 USER\DEVELOPMENT
1074: File (RW-) C:\Windows\winsxs\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_88e046c92fae6f57
1078: File (RW-) C:\Windows\winsxs\amd64_microsoft.vc80.atl_1fc8b3b9a1e18e3b_8.0.50727.4053_none_8a1a02152edb659b
8F4: File (RW-) C:\Windows\winsxs\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_88e046c92fae6f57
908: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP2_RulesLogFiles\1-28-2014_Timer.log
90C: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP2_RulesLogFiles\1-28-2014_Debug.log
928: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP2_RulesLogFiles\1-28-2014_Timer.log
92C: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP2_RulesLogFiles\1-28-2014_Debug.log
948: File (RW-) G:\apps\Oracle\Middleware\user_projects\epmsystem8\products\FinancialManagement\Server Working Folder\APP2_RulesLogFiles\1-28-2014_Timer.log
1064: File (RW-) C:\Windows\winsxs\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_88e046c92fae6f57
1068: File (RW-) C:\Windows\winsxs\amd64_microsoft.vc80.atl_1fc8b3b9a1e18e3b_8.0.50727.4053_none_8a1a02152edb659b
| |
| |
| |
and so on......
我想實現如下:
搜索「數據源的第一個發生然後搜索 第一次出現
(APP1 APP2 APP3 APP4 APP5 APP6 APP7 APP8 APP9)
中的任何一個單詞,我們假設找到APP1單詞,然後 將以下輸出發送到文件'Output.txt':DataSource.exe pid: 5860 USER\DEVELOPMENT APP1
然後搜索「DataSource.exe」的第2個發生,然後再 搜索中
(APP1 APP2 APP3 APP4 APP5 APP6 APP7 APP8 APP9)
字中的任何一項,我們可以放棄它已經被發現的話],並假設APP2第一次發生字 發現然後附加以下輸出到同一個文件 'Output.txt的':DataSource.exe pid: 10568 USER\DEVELOPMENT APP2
等..
我用下面的工作腳本了:
@ECHO OFF
setlocal enabledelayedexpansion
SET "keystring1="
(
FOR /f "delims=" %%a IN (
Source.txt
) DO (
ECHO %%a|FIND "DataSource.exe" >NUL
IF NOT ERRORLEVEL 1 SET keystring1=%%a
FOR %%b IN (APP1 APP2 APP3 APP4 APP5 APP6 APP7 APP8 APP9) DO (
ECHO %%a|FIND "%%b" >NUL
IF NOT ERRORLEVEL 1 IF DEFINED keystring1 CALL ECHO(%%keystring1%% %%b&SET "keystring1="
)))>Output.txt
GOTO :EOF
問題:
我遇到了這裏的問題是一個Source.txt file of size 312 KB
,這個劇本正在4 minutes to produce Output.txt
即使只有9個應用程序,這似乎是相當大時間。
我想減少這個時間,無需使用任何額外的批處理文件。請任何解決方法?
*確切的應用程序名稱與APP1,APP2等不同。
取而代之的搜索過程,然後確定哪些文件已打開,枚舉文件('dir'),併爲他們每個人的判斷是有它鎖定的過程('處理file') –