Search term in specific line in multiple files
Solution 1:
import os
lidir=os.listdir("C://Scripts") #lists all the files
for file in lidir:
fo=open(str("C://Scripts//"+file)) #open the file
content = fo.readlines()
tofindin=""
try:
tofindin = content[30]
except:
continue
x=tofindin.find("getId()") # finds
if x != -1:
print("Present in",file)
You will need to install Python to run this. Also, run this as administrator, because your scripts lie in C: directory. Save this as a '.py' file anywhere.
Solution 2:
You can try Powershell. It is already installed on Windows. Run the following:
Get-ChildItem *.ini | ForEach { $found = (Get-Content $_.name | Select -Index 30 | Select-String "getid\(\)"); if( $found.Length -gt 0){write-host $_.Name} }
Replace *.ini
with your script files' extension.