[CURL]リダイレクト先のファイルサイズ
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
###########【1】リダイレクト先のURLを求める
(*
-I --head ヘッダーのみ
-s サイレント 詳細ログを出さない
-L リダイレクト先の応答を取得
-o /dev/null 出力は捨てる
--write-out -w フォーマットの基づいた結果を表示
*)
set strURL to "https://go.microsoft.com/fwlink/?linkid=2093504" as text
###コマンド整形
set strCommandText to ("/usr/bin/curl --head -s -L -o /dev/null -w '%{url_effective}' \"" & strURL & "\"") as text
##実行
set strRedirectURL to (do shell script strCommandText) as text
###########【2】リダイレクト先のファイル名を求める
set strCommandText to ("/usr/bin/basename \"" & strRedirectURL & "\"") as text
set strFileName to (do shell script strCommandText) as text
########【3】リダイレクト先のファイルのファイルサイズを求める
set strCommandText to ("/usr/bin/curl --head -L \"" & strRedirectURL & "\" | grep \"Content-Length\" | /usr/bin/sed 's/[^0-9]*//g'") as text
##実行
set strFileSize to (do shell script strCommandText) as text
##戻り値
log strFileSize
return strFileSize
| 固定リンク
「CURL」カテゴリの記事
- [curl]rapid-cloudビデオ・ダウンロードヘルパー(簡易式)(2025.01.16)
- CURLでのURLチェック (404以外の応答があるURLのみ収集)(2024.12.03)
- [CURL]ヘッダー付きダウンロード(2024.11.23)
- 【CURL】基本的な事項(2023.10.24)
- [CURL]リダイレクト先URL(2023.10.19)