1

Below is the code i have written for finding 'error' string in particular file and copying result into seperate file.

set today=%date:~-4,4%-%date:~-10,2%-%date:~-7,2%

set day=-1

echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)

echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)

for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"

del "%temp%\%~n0.vbs"

set "YYYY=%result:~0,4%"

set "MM=%result:~4,2%"

set "DD=%result:~6,2%"

set "yesterday=%yyyy%-%mm%-%dd%"




findstr /C:"error" "\\abcd023\peak$\Monitor_5.7\logs\monitor-%today%-0.log" >> C:\a\xyz.txt 


findstr /C:"error" "\\abcd023\peak$\Monitor_5.7\logs\k-server-%yesterday%-0.log.zip\k-server-%yesterday%-0.log" >> C:\a\xyz.txt

k-server-%yesterday%-0.log.zip\ :- as this is the zip file it's giving me error as cannot find the path. For the similar path without zip folder its giving me result.

I want to scan the file which is present in the zip folder without unzipping that folder.

npocmaka
  • 55,367
  • 18
  • 148
  • 187
podduturi
  • 27
  • 4
  • Please read the article [mcve]! Most of the code you provided serves a different purpose than that relevant for the actual problem... Anyway, you cannot search *binary* ZIP files by the *text* search tool `findstr`... – aschipfl Mar 27 '18 at 14:02

1 Answers1

0

Take a look at this: How can I compress (/ zip ) and uncompress (/ unzip ) files and folders with batch file without using any external tools? You can't search in the file content without unzipping it , but you can unzip just a single file. Assuming you have the zipjs.bat in the same directory:

call zipjs.bat unZipItem -source "\\abcd023\peak$\Monitor_5.7\logs\k-server-%yesterday%-0.log.zip\k-server-%yesterday%-0.log" -destination ".\" -keep yes -force yes
findstr /C:"error" ".\k-server-%yesterday%-0.log" >> C:\a\xyz.txt
del /q /f ".\k-server-%yesterday%-0.log"
npocmaka
  • 55,367
  • 18
  • 148
  • 187