基本上我只想浏览我的PE.tmp文件中的每一行,并在test.txt中查找它们,如果找到或不发现,只需调用另一个程序。
脚本
var webRequestHandler = client.HttpMessageHandlers.First() as WebRequestHandler;
if (webRequestHandler != null)
{
var secretRetrieved = keyVault.GetSecretAsync("my-cert");
var pfxBytes = Convert.FromBase64String(secretRetrieved.Result);
// or recreate the certificate directly
var certificate = new X509Certificate2(pfxBytes);
webRequestHandler.ClientCertificates.Add(certificate);
}
Test.txt的
SET "sourcedir=D:\"
SET "FN=%sourcedir%test.txt"
FOR /F "TOKENS=1 DELIMS=." %%A IN (PE.tmp) DO (
FOR /F "TOKENS=1 DELIMS=." %%A IN ('FINDSTR /L /c:"%%A" "%FN%"' set "valpdf=%%A") DO IF %ErrorLevel% EQU 0 (
call :found
) ELSE (
call :notfound
)
)
:found
echo %valpdf%.PDF - %DATE% %time% - Found > LOG.txt
type log.txt >> log1.txt
:notfound
echo %valpdf%.PDF - %DATE% %time% - Not Found > LOG.txt
type log.txt >> log1.txt
PE.tmp
Remote working directory is /
New local directory is D:\PP
local:PP65205861.PDF => remote:/PP65205861.PDF
Listing directory /
-rw------- 1 200 100 12414 June 03 20:05 PP65205861.PDF
New local directory is D:\PE
local:PP65205862.PDF => remote:/PP65205862.PDF
Listing directory /
-rw------- 1 200 100 6763 June 03 20:05 PP65205862.PDF
New local directory is D:\TEMP
Listing directory /
*.PDF: nothing matched
我的结果
PP65205861.PDF
PP65205862.PDF
期望的结果
.PDF - 05/05/2017 10:56:39.59 - Found
.PDF - 05/05/2017 10:56:39.60 - Not Found
有效的脚本
PP65205861.PDF - 05/05/2017 10:56:39.59 - Found
PP65205862.PDF - 05/05/2017 10:56:39.59 - Found
答案 0 :(得分:0)
要获得所需的结果,请执行以下操作:
:: Q:\Test\2017-05\05\SO_43795847.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
Set "sourcedir=D:\"
Set "FN=%sourcedir%test.txt"
For /F "DELIMS=" %%A IN (PE.tmp) DO (
Set "Found=Not Found"
FOR /F "DELIMS=" %%B IN ('FINDSTR /L /c:"%%A" "%FN%"' ) DO Set "Found=Found"
Echo %%A - %DATE% %time% - !Found! > LOG.txt
Type log.txt >> log1.txt
)