I was trying to get the latest
<a href>
link i.e 122 from below temp.txt file
`<html>
<head><meta name="robots" content="noindex" />
<title>test</title>
</head>
<body>
<h1>test</h1>
</pre><hr/>
<pre><a href="../">../</a>
<a href="100/">100/</a> 23-Mar-2022 17:12 -
<a href="111/">111/</a> 21-Mar-2023 12:08 -
<a href="112/">112/</a> 18-Apr-2023 07:46 -
<a href="113/">113/</a> 25-May-2023 21:15 -
----
<a href="120/">120/</a> 11-Dec-2023 10:43 -
<a href="121/">121/</a> 30-Jan-2024 07:31 -
**<a href="122/">122/</a> 11-Mar-2024 06:00 -**
<a href="93/">93/</a> 24-Aug-2021 16:07 -
<a href="94/">94/</a> 12-Oct-2021 11:21 -
<a href="95/">95/</a> 26-Oct-2021 16:25 -
<a href="97/">97/</a> 06-Jan-2022 15:23 -
<a href="98/">98/</a> 07-Feb-2022 16:04 -
<a href="99/">99/</a> 10-Mar-2022 12:18 -
<a href="json/">json/</a> 03-Apr-2024 04:26 -
<a href="linux/">linux/</a> 17-Jun-2020 12:06 -
<a href="known-good-version-with-downloads.json">known-good-version-with-downloads.json</a> 01-Apr-2024 07:03 1.39 KB
</pre>
<hr/><address style="font-size:small;">Artifactory/7.49.12 Server at artifactrepository.xxxxxx.net Port 80</address></body></html> `
I have used below batch script
@echo off
setlocal enabledelayedexpansion
set "latestHref="
for /f "tokens=*" %%a in ('type temp.txt ^| findstr /i "href="') do (
set "href=%%a"
set "href=!href:*href=!"
for /f "tokens=2 delims==" %%b in ("!href!") do (
set "latestHref=%%~b"
)
)
if defined latestHref (
echo Latest href link: !latestHref!
) else (
echo No href links found in the text file.
)
but every time i am getting No href links found in the text file can someone help me pls
I was expecting 122 in the result , but still getting wrong result
New contributor
Arul Suju is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.