Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8087

Профиль | Отправить PM | Цитировать


Например, так:
curl.exe
Код: Выделить весь код
@echo off
setlocal enableextensions enabledelayedexpansion

set sSourceFile=%~1

if defined sSourceFile (
	if exist "%sSourceFile%" (
		>"UrlsExists.txt" (
			for /f "usebackq delims=" %%i in ("%sSourceFile%") do (
				>nul 2>&1 "C:\Program Files (x86)\curl\curl.exe" --output nul --silent --head --fail --url "%%~i" && echo %%~i
			)
		)
	) else (
		echo Can't find source file [%sSourceFile%].
		exit /b 2
	)
) else (
	echo Usage: %~nx0 ^<Source file^>
	exit /b 1
)

endlocal
exit /b 0
Путь к исходному файлу указывается аргументом пакетного файла.

wget.exe
Код: Выделить весь код
@echo off
setlocal enableextensions enabledelayedexpansion

set sSourceFile=%~1

if defined sSourceFile (
	if exist "%sSourceFile%" (
		>"UrlsExists.txt" (
			for /f "usebackq delims=" %%i in ("%sSourceFile%") do (
				>nul 2>&1 "C:\Program Files (x86)\GnuWin32\bin\wget.exe" --spider --no-dns-cache --no-cache --quiet "%%~i" && echo %%~i
			)
		)
	) else (
		echo Can't find source file [%sSourceFile%].
		exit /b 2
	)
) else (
	echo Usage: %~nx0 ^<Source file^>
	exit /b 1
)

endlocal
exit /b 0
Путь к исходному файлу указывается аргументом пакетного файла.

PowerShell
Проверялось на версии 5.0:
Код: Выделить весь код
$sSourseFileList = 'C:\Мои проекты\0070\Urls.txt'
$sDestFileList   = 'C:\Мои проекты\0070\UrlsExists.txt'


if(Test-Path -Path $sSourseFileList -PathType Leaf) {
    $aContent = Get-Content -Path $sSourseFileList
    
    if(Test-Path -Path $sDestFileList -PathType Leaf) {
        Remove-Item -Path $sDestFileList -Force
    }

    foreach($sUrl in $aContent) {
        Write-Host "Checking [$sUrl]…`t" -NoNewline -ForegroundColor DarkGreen

        try {
            $oHtmlWebResponseObject = Invoke-WebRequest -Uri $sUrl -Method Head -UseBasicParsing -ErrorAction Stop
        } catch {
            Write-Host "Failure" -ForegroundColor Red
            $oHttpStatusCode = $_.Exception.Response.StatusCode
            Write-Host "Can't load [$sUrl] ($($oHttpStatusCode.value__): $oHttpStatusCode)" 
            continue
        }

        Write-Host "OK" -ForegroundColor Green
        Add-Content -Path $sDestFileList -Value $sUrl
    }
} else {
    Write-Host "Can't find source file $sSourseFileList." -ForegroundColor Red
}
Это сообщение посчитали полезным следующие участники:

Отправлено: 11:23, 07-05-2017 | #4