Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Check URL using DOS script

21 Nov 2014   #1
born2achieve

windows7 64 bit
 
 
Check URL using DOS script

Hi,

I am using windows7 64 bit. I have a text file "sample.txt" and text file has 200000 image url's as like below


http://www.imagesup.net/img/icon_index1.png
http://www.imagesup.net/img/icon_index2.png
http://www.imagesup.net/img/icon_index3.png
http://www.imagesup.net/img/icon_index3.png
http://www.imagesup.net/img/icon_index5.png
http://www.imagesup.net/img/icon_index6.png
http://www.imagesup.net/img/icon_index7.png
http://www.imagesup.net/img/icon_index8.png
........

I wanted to check the image existson the directory, All my images are hosted remotely.Is it possible to achive using the batch script? if i executhe batch, it should output the url which doesn't have the image on output.txt file. Is it possible to achieve using DOS script. any sampel code please

Thanks


My System SpecsSystem Spec
.
21 Nov 2014   #2
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Can you post the txt file somewhere (preferable zipped) and post a link to it?

you just want to check if http://www.imagesup.net/img/icon_index6.png exists? (and that very a lot of files). So the files have to be checked on the webserver. is that a linux or windows machine?
My System SpecsSystem Spec
21 Nov 2014   #3
born2achieve

windows7 64 bit
 
 

Hi,

thanks for your reply and it's windows server. but i don't have access to the server. Is it possible to check from m y local machine? could you please assist me
My System SpecsSystem Spec
.

22 Nov 2014   #4
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Is it just a large number of url's you want to check?
each line in txt file has 1 url?

Post the txt file zipped please
My System SpecsSystem Spec
22 Nov 2014   #5
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Step 1 :create an empty file named results.log
Step 2:
WGET http://www.somehost.com/folder/subfolder/filename.png > null:
IF %ERRORLEVEL% echo http://www.somehost.com/folder/subfolder/filename.png >> results.log

of course you have to install wget


My System SpecsSystem Spec
22 Nov 2014   #6
born2achieve

windows7 64 bit
 
 

Hey Dude,

thanks for the reply and Finally i was able to install the GetGnuwin32 and i did all the installation specified in the document. Now i could see the Wget exe and i tried to

D:\GnuWin32\GetGnuWin32\bin> wget.exe http://pagead2.googlesyndication.com...32194530698365

I could see the result on the command prompt and i can see the image downloaded on the root folder. Now Could you please help me on reading the URL.txt has 200000 urls and need to output which URL has doesn't have image on output.txt.

[Note: I don't want to download the image to my folder. I just need
get the URL which doesn't have image]

could you please help on making this process as batch script


Any help please.
My System SpecsSystem Spec
23 Nov 2014   #7
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Can you post the txt file. Best to zip it first.
I want to see the format and test. Or you don't want that due to privacy???
I that case post only a small part
My System SpecsSystem Spec
23 Nov 2014   #8
Tookeri

Windows 7 Pro 32
 
 

I made a small batch file, no third-party tools used. But this solution is going to be very slow and might take days if you have 200000 URLs to check! I suggest you do a small test first like I've done.

This batch file assumes you run it from the folder where the sample.txt file is. As content for my sample.txt file I used the URLs listed in your first post + added 4 URLs for pictures that actually exist. None of the URLs from your first post works.

sample.txt content:
http://www.imagesup.net/img/icon_index1.png
http://www.imagesup.net/img/icon_index2.png
http://www.imagesup.net/img/icon_index3.png
http://www.imagesup.net/img/icon_index3.png
http://www.imagesup.net/img/icon_index5.png
http://www.imagesup.net/img/icon_index6.png
http://www.imagesup.net/img/icon_index7.png
http://www.imagesup.net/img/icon_index8.png
http://www.sevenforums.com/images/st...c/r1sha-1c.jpg
http://www.sevenforums.com/images/ranks/MCC130c.png
http://www.theregister.co.uk/Design/.../std/rlogo.png
https://images.cdn.static.malwarebyt...eader-logo.jpg

The batch file:
Code:
@ECHO OFF

REM Only URLs that failed will be printed

REM Create Vbscript to check URL:
 >"TestURL.vbs" echo URL = wscript.arguments(0)
>>"TestURL.vbs" echo Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
>>"TestURL.vbs" echo objXMLHTTP.open "GET", URL, false
>>"TestURL.vbs" echo objXMLHTTP.send()
>>"TestURL.vbs" echo While Not objXMLHTTP.ReadyState = 4
>>"TestURL.vbs" echo     Sleep 10
>>"TestURL.vbs" echo Wend
>>"TestURL.vbs" echo If Not objXMLHTTP.Status = 200 Then
>>"TestURL.vbs" echo     WScript.Echo(URL)
>>"TestURL.vbs" echo End if
>>"TestURL.vbs" echo Set objXMLHTTP = Nothing

REM Read each line in txt file and call the Vbscript with the line as parameter:
for /F "delims=" %%a in (sample.txt) do (
    cscript /nologo TestURL.vbs "%%a"
)
Output when I run the batch file:
http://www.imagesup.net/img/icon_index1.png
http://www.imagesup.net/img/icon_index2.png
http://www.imagesup.net/img/icon_index3.png
http://www.imagesup.net/img/icon_index3.png
http://www.imagesup.net/img/icon_index5.png
http://www.imagesup.net/img/icon_index6.png
http://www.imagesup.net/img/icon_index7.png
http://www.imagesup.net/img/icon_index8.png
Only the failed URLs were listed. Not the 4 URLs I added.

For testing purposes the batch file won't write to output.txt but when you've tested it and want to create the output.txt file you run the batch file like this that will print to the file instead of the command window:
nameOfBatchFile > output.txt
My System SpecsSystem Spec
23 Nov 2014   #9
born2achieve

windows7 64 bit
 
 

Hey Dude,

Finally i was able to install the GetGnuwin32 and i did all the installation specified in the document. Now i could see the Wget exe and i tried to

D:\GnuWin32\GetGnuWin32\bin> wget.exe http://pagead2.googlesyndication.com/si ... 4530698365

I could see the result on the command prompt and i can see the image downloaded on the root folder. Now Could you please help me on reading the URL.txt has 200000 urls and need to output which URL has doesn't have image on output.txt.
then i tried to achieve the ecat output by below code,

Code:
@echo off
(for /f "usebackq delims=" %%a in ("url-list.txt") do (
    "D:\GnuWin32\GetGnuWin32\bin\wget.exe" --spider "%%a" || echo missing %%a
))>url.log
pause
i am good now. but seems to be this is not fastest way i am looking for as it takes plenty of time to output the result. please guide me with the fastest way to achieve this
My System SpecsSystem Spec
24 Nov 2014   #10
born2achieve

windows7 64 bit
 
 

Hey Guyz,

thakns for all your timely help and could you please help on achieving this faster. Any suggestions please
My System SpecsSystem Spec
Reply

 Check URL using DOS script




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Dos script help
Hi, Below is my folder path, D:/Sample I have .sql files in that folder and i need to get the file names based on modified/created date i pass. for ex : i need to get the file names created/modified on or after 10/01/2014(mm/dd/yyyy). Can any please give me some sample script to make this...
General Discussion
Check Internet connectivity automatically via script and reconnect
Hi all I have a few computers that connect via rasdial to a bridged modem. They are dropping off randomly and frequently enough that its a pain to have to reset them manually everytime. Does anyone know how I could write a script or something that would check for internet connectivity and if...
Network & Sharing
Script to Check Processes then Launch
I would like a script that does the following: If ProcessA.exe NOT Running? Open ProgramA (Access link file) End If If ProcessB.exe NOT Running? Open ProgramB (Access link file) End If
General Discussion
In need of a script...
I am looking for a script which can delete cookies, Windows + browser cache automatically on a regular (scheduled) basis. Can this be done through Windows itself or would i have to implement a custom script or something? I am looking to replace CCleaner and similar software package(s). Just now...
Performance & Maintenance


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 03:21.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App