AppleScript XML webloc

インターネット・ロケーションファイルまとめ(inetlocファイル追記分)

20240326060434642x414

inetloc インターネットロケーションファイルには
URL部分にデータが入っているケースがあった
202403260605031112x450

Base64でエンコードされているだけなので、画像でータの取り出しは比較的簡単
[inetloc] inetlocのURLがBASE64エンコードされたデータの場合の取り出し方(HTMLにしちゃう版)
https://quicktimer.cocolog-nifty.com/icefloe/2024/03/post-0a7314.html



以下変更無し
Screen-20230911-93240


ダウンロード - webloc.zip




AFP.afploc
AFPサーバーへのリンクファイル

[AfpLoc] afpサーバーへのリンクファイルを作る(afp://)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-af3be0.html
FILE.fileloc
ファイル・フォルダへのリンクファイル

[FileLoc] ファイルのリンクファイルを作る(file://)ファイル選択
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-99ee9e.html
[FileLoc] フォルダのリンクファイルを作る(file://)フォルダ選択
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-88b291.html
[FileLoc] ファイルやフォルダのリンクファイルを作る(file://)パス入力
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-384039.html
FTP.ftploc
FTPサーバーへのリンクファイル

[FtpLoc] FTPサーバーのFtpLocリンクファイルを作る(ftp://)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-557534.html
HTTP.webloc
WEBサーバーへのリンクファイル

[WebLoc]WebLocファイルを作る(Safari)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-026999.html
[WebLoc]WebLocファイルを作る(Chrome)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-b24690.html
[WebLoc]WebLocファイルを作る(Edge)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-2f6c2c.html
MAIL.mailloc
メールアドレスリンク

[MailLoc] メールアドレスのmaillocファイルを作る(mailto)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-cc18f0.html
NEWS.newsloc
ニュース(Usenet)サーバーへのリンクファイル

[NewsLoc] Usenet newsサーバーのnewslocファイルを作る(Usenet)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-7a166f.html
SMB.inetloc
SMBサーバーへのリンクファイル

[inetloc] SMBサーバーへのリンクファイルを作る(SMB)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-9b0084.html
SSH.inetloc
SSHサーバーへのリンクファイル

[inetloc] SSHサーバーへのリンクinetlocファイルを作る(SSH)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-2e9950.html
CalLoc.inetloc
カレンダーサーバーへのリンクファイル

[inetloc] カレンダーサーバーに対してのリンクファイルを作る(webcal)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-45c42b.html


WindowsのURLファイル(ショートカットファイル)
WindowのURLファイル(ショートカットファイル)を作る
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-749751.html
inetlocファイルをWindowsのURLファイルに変換する
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-9c2964.html

|

[inetloc] inetlocのURLがBASE64エンコードされたデータの場合の取り出し方(HTMLにしちゃう版)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

set appFileManager to refMe's NSFileManager's defaultManager()

###################################
#####ファイル選択ダイアログ
###################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder"
activate
  end tell
else
  tell current application
activate
  end tell
end if
####ダイアログを出す
set listUTI to {"com.apple.property-list", "com.apple.generic-internet-location"} as list
set aliasFilePath to (choose file with prompt "plistファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
####入力ファイルパス
set strFilePath to POSIX path of aliasFilePath
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
set ocidPrefixName to ocidBaseFilePathURL's lastPathComponent()
###################################
##保存先ディレクトリの確保
###################################
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTempDirURL to appFileManager's temporaryDirectory()
#上書きできないようにUUIDで別名フォルダにする
set ocidUUID to refMe's NSUUID's alloc()'s init()
set ocidUUIDString to ocidUUID's UUIDString
set ocidSaveDirPathURL to ocidTempDirURL's URLByAppendingPathComponent:(ocidUUIDString) isDirectory:true
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
#アクセス権777=511を指定
ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
#保存ファイル名
set strFileName to ((ocidUUIDString as text) & ".html") as text
#保存先URL
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:false


###################################
#####本処理
###################################
# DICTに読み込んで
set listResponse to refMe's NSDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL) |error|:(reference)
set ocidReadData to (item 1 of listResponse)
#
set ocidURL64 to ocidReadData's objectForKey:("URL")

########################
##HTML生成開始
########################
##Header に渡すエレメント
set ocidSetHeaderElement to (refMe's NSXMLElement's elementWithName:("div"))
set ocidH3Element to (refMe's NSXMLElement's elementWithName:("h3"))
set strSetValue to ("InetLocのURLがBase64フォーマットの画像") as text
(ocidH3Element's setStringValue:(strSetValue))
(ocidSetHeaderElement's addChild:(ocidH3Element))
########################
#footerに渡すエレメント
set ocidSetFooterElement to (refMe's NSXMLElement's elementWithName:("div"))
set ocidAElement to (refMe's NSXMLElement's elementWithName:("a"))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:("https://quicktimer.cocolog-nifty.com/"))
(ocidAElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank"))
(ocidAElement's addAttribute:(ocidAddNode))
set strSetValue to ("AppleScriptで生成しました") as text
(ocidAElement's setStringValue:(strSetValue))
(ocidSetFooterElement's addChild:(ocidAElement))
########################
#Articleに渡すエレメント
set ocidSetArticleElement to (refMe's NSXMLElement's elementWithName:("div"))
set ocidH3Element to (refMe's NSXMLElement's elementWithName:("h3"))
set strSetValue to ("InetLocからの収集: ") as text
(ocidH3Element's setStringValue:(strSetValue))
(ocidSetArticleElement's addChild:(ocidH3Element))

########################
#テーブル部生成開始
set ocidTableElement to refMe's NSXMLElement's elementWithName:("table")
#####【caption】
set ocidCaptionElement to refMe's NSXMLElement's elementWithName:("caption")
ocidCaptionElement's setStringValue:("InetLocから取得")
ocidTableElement's addChild:(ocidCaptionElement)
#####【colgroup】
set ocidColgroupElement to refMe's NSXMLElement's elementWithName:("colgroup")
#タイトル部の数だけ繰り返し
set listColName to {"LineNO", "Value"}
repeat with itemColName in listColName
  #######【col】col生成
  set ocidAddElement to (refMe's NSXMLElement's elementWithName:("col"))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
(ocidColgroupElement's addChild:(ocidAddElement))
end repeat
#テーブルエレメントに追加
ocidTableElement's addChild:(ocidColgroupElement)
#######【thead】
set ocidTheadElement to refMe's NSXMLElement's elementWithName:("thead")
#TR
set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr")
set listColName to {"\", "Value"}
#タイトル部の数だけ繰り返し
repeat with itemColName in listColName
  #ここはTDではなくてTHを利用
  set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
  #
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:(itemColName))
(ocidAddElement's addAttribute:(ocidAddNode))
  set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidAddElement's addAttribute:(ocidAddNode))
  #値を入れる
(ocidAddElement's setStringValue:(itemColName))
  #TH→TRにセット
(ocidTrElement's addChild:(ocidAddElement))
end repeat
#TRをTHEADにセット
ocidTheadElement's addChild:(ocidTrElement)
#THEADをテーブルにセット
ocidTableElement's addChild:(ocidTheadElement)
##################################
######【tbody】
set ocidTbodyElement to refMe's NSXMLElement's elementWithName:("tbody")
##############
#TRの開始
set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
#
set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("項目番号:"))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:("NameID"))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("rowspan") stringValue:("2"))
(ocidThElement's addAttribute:(ocidAddNode))
(ocidThElement's setStringValue:("1"))
(ocidTrElement's addChild:(ocidThElement))
##################################

##################################
set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("videoId"))
(ocidTdElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:("key"))
(ocidTdElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
(ocidTdElement's addAttribute:(ocidAddNode))
#######
set ocidImgElement to (refMe's NSXMLElement's elementWithName:("img"))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("src") stringValue:(ocidURL64))
(ocidImgElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("alt") stringValue:("base64image"))
(ocidImgElement's addAttribute:(ocidAddNode))
#
(ocidTdElement's addChild:(ocidImgElement))
(ocidTrElement's addChild:(ocidTdElement))
(ocidTbodyElement's addChild:(ocidTrElement))
#Tbodyをテーブルにセット
ocidTableElement's addChild:(ocidTbodyElement)

######【tfoot】 TRで
set ocidTfootElement to refMe's NSXMLElement's elementWithName:("tfoot")
set ocidTrElement to refMe's NSXMLElement's elementWithName:("tr")

#colspan指定して1行でセット
set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("テーブルの終わり"))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("colspan") stringValue:("2"))
(ocidThElement's addAttribute:(ocidAddNode))
set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("row"))
(ocidThElement's addAttribute:(ocidAddNode))
#
set strContents to ("URL内容です") as text
(ocidThElement's setStringValue:(strContents))
#THをTRにセットして
ocidTrElement's addChild:(ocidThElement)
#TRをTFOOTにセット
ocidTfootElement's addChild:(ocidTrElement)
#TFOOTをテーブルにセット
ocidTableElement's addChild:(ocidTfootElement)
ocidSetArticleElement's addChild:(ocidTableElement)

##############################
#HTMLにする
##############################
set ocidHTML to doMakeRootElement({ocidSetHeaderElement, ocidSetArticleElement, ocidSetFooterElement})

#####保存
#読み取りやすい表示
set ocidXMLdata to ocidHTML's XMLDataWithOptions:(refMe's NSXMLNodePrettyPrint)

set listDone to ocidXMLdata's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error|:(reference)

####ブラウザで開く
set aliasFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
tell application "Finder"
open location aliasFilePath
end tell

##############################
# 基本的なHTMLの構造
(*
doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents})
HTMLのBODY部
header
article
footerにそれぞれAddchildするデータをリストで渡す
戻り値はRootエレメントにセットされた
NSXMLDocumentを戻すので 保存すればOK
*)
##############################
to doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents})
  #XML初期化
  set ocidXMLDoc to refMe's NSXMLDocument's alloc()'s init()
ocidXMLDoc's setDocumentContentKind:(refMe's NSXMLDocumentHTMLKind)
  # DTD付与
  set ocidDTD to refMe's NSXMLDTD's alloc()'s init()
ocidDTD's setName:("html")
ocidXMLDoc's setDTD:(ocidDTD)
  #
  set ocidRootElement to refMe's NSXMLElement's elementWithName:("html")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("lang") stringValue:("ja")
ocidRootElement's addAttribute:(ocidAddNode)
  #
  set ocidHeadElement to refMe's NSXMLElement's elementWithName:("head")
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("title")
ocidAddElement's setStringValue:("RSS一覧")
ocidHeadElement's addChild:(ocidAddElement)
  # http-equiv
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Type")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/html; charset=UTF-8")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Style-Type")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/css")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Script-Type")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/javascript")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("name") stringValue:("viewport")
ocidAddElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("width=720")
ocidAddElement's addAttribute:(ocidAddNode)
ocidHeadElement's addChild:(ocidAddElement)
  #
  set ocidAddElement to refMe's NSXMLElement's elementWithName:("style")
ocidAddElement's setStringValue:("body {margin: 10px;background-color: #FFFFFF;}img {max-width: 720px;}table {border-spacing: 0;caption-side: top;font-family: system-ui;}thead th {border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;&:first-of-type {border-start-start-radius: .5em}&:last-of-type {border-start-end-radius: .5em;border-inline-end-width: 1px}}tbody td {word-wrap: break-word;max-width: 720px;border-spacing: 0;border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;&:last-of-type {border-inline-end-width: 1px}}tbody th {border-spacing: 0;border: solid 1px #666666;padding: .5ch 1ch;border-block-width: 1px 0;border-inline-width: 1px 0;}tbody tr:nth-of-type(odd) {background: #F2F2F2;}.kind_string {font-size: 0.75em;}.date_string {font-size: 0.5em;}tfoot th {border: solid 1px #666666;padding: .5ch 1ch;&:first-of-type {border-end-start-radius: .5em}&:last-of-type {border-end-end-radius: .5em;border-inline-end-width: 1px}}")
ocidHeadElement's addChild:(ocidAddElement)
ocidRootElement's addChild:(ocidHeadElement)
  #
  #ボディエレメント
  set ocidBodyElement to refMe's NSXMLElement's elementWithName:("body")
  #ヘッダー
  set ocidHeaderElement to refMe's NSXMLElement's elementWithName:("header")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("header")
ocidHeaderElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_header")
ocidHeaderElement's addAttribute:(ocidAddNode)
ocidHeaderElement's addChild:(argHeaderContents)
ocidBodyElement's addChild:(ocidHeaderElement)
  #アーティクル
  set ocidArticleElement to refMe's NSXMLElement's elementWithName:("article")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("article")
ocidArticleElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_article")
ocidArticleElement's addAttribute:(ocidAddNode)
ocidArticleElement's addChild:(argArticleContents)
ocidBodyElement's addChild:(ocidArticleElement)
  #フッター
  set ocidFooterElement to refMe's NSXMLElement's elementWithName:("footer")
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("footer")
ocidFooterElement's addAttribute:(ocidAddNode)
  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_footer")
ocidFooterElement's addAttribute:(ocidAddNode)
ocidFooterElement's addChild:(argFooterContents)
ocidBodyElement's addChild:(ocidFooterElement)
  
ocidRootElement's addChild:(ocidBodyElement)
ocidXMLDoc's setRootElement:(ocidRootElement)
return ocidXMLDoc
end doMakeRootElement

|

インターネット・ロケーションファイルまとめ

Screen-20230911-93240



ダウンロード - webloc.zip




AFP.afploc
AFPサーバーへのリンクファイル

[AfpLoc] afpサーバーへのリンクファイルを作る(afp://)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-af3be0.html
FILE.fileloc
ファイル・フォルダへのリンクファイル

[FileLoc] ファイルのリンクファイルを作る(file://)ファイル選択
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-99ee9e.html
[FileLoc] フォルダのリンクファイルを作る(file://)フォルダ選択
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-88b291.html
[FileLoc] ファイルやフォルダのリンクファイルを作る(file://)パス入力
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-384039.html
FTP.ftploc
FTPサーバーへのリンクファイル

[FtpLoc] FTPサーバーのFtpLocリンクファイルを作る(ftp://)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-557534.html
HTTP.webloc
WEBサーバーへのリンクファイル

[WebLoc]WebLocファイルを作る(Safari)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-026999.html
[WebLoc]WebLocファイルを作る(Chrome)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-b24690.html
[WebLoc]WebLocファイルを作る(Edge)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-2f6c2c.html
MAIL.mailloc
メールアドレスリンク

[MailLoc] メールアドレスのmaillocファイルを作る(mailto)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-cc18f0.html
NEWS.newsloc
ニュース(Usenet)サーバーへのリンクファイル

[NewsLoc] Usenet newsサーバーのnewslocファイルを作る(Usenet)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-7a166f.html
SMB.inetloc
SMBサーバーへのリンクファイル

[inetloc] SMBサーバーへのリンクファイルを作る(SMB)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-9b0084.html
SSH.inetloc
SSHサーバーへのリンクファイル

[inetloc] SSHサーバーへのリンクinetlocファイルを作る(SSH)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-2e9950.html
CalLoc.inetloc
カレンダーサーバーへのリンクファイル

[inetloc] カレンダーサーバーに対してのリンクファイルを作る(webcal)
https://quicktimer.cocolog-nifty.com/icefloe/2023/09/post-45c42b.html


WindowsのURLファイル(ショートカットファイル)
WindowのURLファイル(ショートカットファイル)を作る
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-749751.html
inetlocファイルをWindowsのURLファイルに変換する
https://quicktimer.cocolog-nifty.com/icefloe/2023/12/post-9c2964.html

|

ファイルパスからFILELOCファイルを作成する


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()
##デフォルトクリップボードから
set appPasteboard to refMe's NSPasteboard's generalPasteboard()
set ocidPastBoardTypeArray to appPasteboard's types()
set boolContainURL to ocidPastBoardTypeArray's containsObject:"public.file-url"
if boolContainURL is true then
  set ocidObjectArray to appPasteboard's readObjectsForClasses:({refMe's NSURL}) options:(missing value)
  set ocidObject to ocidObjectArray's firstObject()
  set strURL to ocidObject's |path|() as text
else
  set strURL to ("/some/path/file/or/dir") as text
end if
################################
######ダイアログ
################################
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set aliasIconPath to (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns") as alias
try
  set strMes to ("ファイルパスを入力してください\n例:\n/some/path/file/or/dir\n~/Desktop") as text
  set recordResponse to (display dialog strMes with title "ファイルパスを入力してください" default answer strURL buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 20 without hidden answer)
on error
log "エラーしました"
return "エラーしました"
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
end if
if "OK" is equal to (button returned of recordResponse) then
  set strResponse to (text returned of recordResponse) as text
else
log "キャンセルしました"
return "キャンセルしました"
end if

if strResponse starts with "/" then
  set ocidFilePathStr to refMe's NSString's stringWithString:(strResponse)
else if strResponse starts with "~" then
  set ocidFilePathStr to refMe's NSString's stringWithString:(strResponse)
else
return "ファイルパス専用です"
end if
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath))
set strURL to ocidFilePathURL's absoluteString() as text
###ファイル名を取得して拡張子を取っておく
set ocidBaseNamePathURL to ocidFilePathURL's URLByDeletingPathExtension()
set strBaseFileName to (ocidBaseNamePathURL's lastPathComponent()) as text
###保存用のファイル名
set strSaveFileName to (strBaseFileName & ".fileloc") as text
###保存先はデスクトップ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set ocidSaveFilePathURL to ocidDesktopDirPathURL's URLByAppendingPathComponent:(strSaveFileName)
###PLIST用のURLの値
set strURL to (ocidFilePathURL's absoluteString()) as text
##############################
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidPlistDict's setValue:(strURL) forKey:("URL")
###
set ocidFromat to refMe's NSPropertyListXMLFormat_v1_0
set listPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidPlistDict) format:(ocidFromat) options:0 |error|:(reference)
set ocidPlistData to item 1 of listPlistEditDataArray
###
set listDone to ocidPlistData's writeToURL:(ocidSaveFilePathURL) options:0 |error|:(reference)




|

WindowのURLファイル(ショートカットファイル)を作る


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#【注意事項】ユーザー名パスワードを指定する場合パスワードが平文で保存されます
#そのため、ユーザー名パスワードを指定するのは非推奨です
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


##デフォルトクリップボードから
set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
set ocidPasteboardArray to ocidPasteboard's readObjectsForClasses:({refMe's NSString}) options:(missing value)
try
  set ocidPasteboardStrings to (ocidPasteboardArray's objectAtIndex:0) as text
on error
  set ocidPasteboardStrings to "" as text
end try
set strDefaultAnswer to ocidPasteboardStrings as text
if strDefaultAnswer starts with "ssh:" then
  set strURL to strDefaultAnswer as text
else
  set strURL to ("http://") as text
end if


################################
######ダイアログ
################################
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set aliasIconPath to (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns") as alias
try
  set strMes to ("サーバーのURLを入力してください\n例:\nhttps://yahoo.co.jp\nsmb://USERID:PASSWORD@192.168.0.0\nssh://localhost\nfile:///Applications") as text
  
  set recordResponse to (display dialog strMes with title "SSHのURLを入力してください" default answer strURL buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 20 without hidden answer)
on error
log "エラーしました"
return "エラーしました"
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
end if
if "OK" is equal to (button returned of recordResponse) then
  set strResponse to (text returned of recordResponse) as text
else
log "キャンセルしました"
return "キャンセルしました"
end if

###タブと改行の除去
set ocidURL to refMe's NSString's stringWithString:(strResponse)
set ocidURLM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
ocidURLM's appendString:(ocidURL)
##行末の改行
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\n") withString:("")
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\r") withString:("")
##タブ除去
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\t") withString:("")

set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLM)
set ocidURLStr to ocidURL's absoluteString()
set strURLStr to ocidURLStr as text
set ocidHostName to ocidURL's |host|() as text
log ocidHostName
##ファイル名
set strFileName to (ocidHostName & ".url") as text

##############################
## 保存先ディレクトリ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/Webloc/WinURL/") isDirectory:(true)
##ディレクトリ作成
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###保存ファイルURL
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
###Finder 用のエイリアス
set aliasSaveDirPath to (ocidSaveDirPathURL's absoluteURL()) as alias
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
#########################
set ocidSaveStrings to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
(ocidSaveStrings's appendString:("[InternetShortcut]\r\n"))
set strSetString to ("URL=" & strURLStr & "\r\n") as text
(ocidSaveStrings's appendString:(strSetString))
##重複チェック
set ocidDistFilePath to doChkExists(ocidSaveFilePathURL)
set ocidDistFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDistFilePath) isDirectory:false)
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
set strDistFilePath to ocidDistFilePathURL's |path| as text
if strSaveFilePath is strDistFilePath then
log "置換します"
  #今あるファイルをゴミ箱に
  set appFileManager to refMe's NSFileManager's defaultManager()
  set listResult to (appFileManager's trashItemAtURL:(ocidDistFilePathURL) resultingItemURL:(ocidDistFilePathURL) |error|:(reference))
  #保存
  set listDone to (ocidSaveStrings's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
else
  #保存
  set listDone to (ocidSaveStrings's writeToURL:(ocidDistFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
end if
set boolDone to (item 1 of listDone) as boolean
if boolDone is false then
return "移動に失敗しました"
end if
####保存先を開く
tell application "Finder"
  set aliasSaveFile to (file strFileName of folder aliasSaveDirPath) as alias
  set refNewWindow to make new Finder window
  tell refNewWindow
    set position to {10, 30}
    set bounds to {10, 30, 720, 480}
  end tell
  set target of refNewWindow to aliasSaveDirPath
  set selection to aliasSaveFile
end tell

#########################
####バージョンで使う日付
to doGetDateNo(strDateFormat)
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
ocidNSDateFormatter's setDateFormat:strDateFormat
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo





####################################
#上書きチェック
# ocid file path = NSPathStore を返します
####################################
to doChkExists(argFilePath)
log (className() of argFilePath) as text
  if (class of argFilePath) is text then
log "テキストファイルパス"
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (class of argFilePath) is alias then
log "エリアスファイルパス"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (class of argFilePath) is «class furl» then
log "エリアスfurlファイルパス"
    set aliasFilePath to argFilePath as alias
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (className() of argFilePath as text) contains "NSCFString" then
log "NSStringファイルパス"
    set ocidArgFilePath to argFilePath's stringByStandardizingPath()
  else if (className() of argFilePath as text) contains "NSPathStore" then
log "NSPathStore2ファイルパス"
    set ocidArgFilePath to argFilePath
  else if (className() of argFilePath as text) contains "NSURL" then
log "NSURLファイルパス"
    set ocidArgFilePath to argFilePath's |path|
  end if
  ####
  set appFileManager to refMe's NSFileManager's defaultManager()
  set boolExists to appFileManager's fileExistsAtPath:(ocidArgFilePath) isDirectory:(false)
  #
  if boolExists = true then
    ##ダイアログを前面に
    set strName to (name of current application) as text
    if strName is "osascript" then
      tell application "Finder" to activate
    else
      tell current application to activate
    end if
    set strMes to "上書きします?" as text
    try
      set objResponse to (display alert strMes buttons {"上書きする", "処理を中止する", "ファイル名を変更"} default button "上書きする" cancel button "処理を中止する" as informational giving up after 20)
    on error
log "処理を中止しました"
return "処理を中止しました"
      error number -128
    end try
    if true is equal to (gave up of objResponse) then
log "時間切れですやりなおしてください"
return "時間切れですやりなおしてください"
      error number -128
    end if
    if "上書きする" is equal to (button returned of objResponse) then
log "上書き保存します"
      set ocidReturnFilePath to ocidArgFilePath
    else if "ファイル名を変更" is equal to (button returned of objResponse) then
log "ファイル名を変更"
      set ocidContainerDirFilePath to ocidArgFilePath's stringByDeletingLastPathComponent()
      set strFileName to ocidArgFilePath's lastPathComponent() as text
      set aliasContainerDirPath to (POSIX file (ocidContainerDirFilePath as text)) as alias
      ##
      set strPromptText to "名前を決めてください" as text
      set strMesText to "名前を決めてください" as text
      ###ファイル名 ダイアログ
      set aliasFilePath to (choose file name strMesText default location aliasContainerDirPath default name strFileName with prompt strPromptText) as «class furl»
      set strFilePath to (POSIX path of aliasFilePath) as text
      set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
      set ocidReturnFilePath to ocidFilePathStr's stringByStandardizingPath()
    else if "処理を中止する" is equal to (button returned of objResponse) then
return "処理を中止しました"
    else
return "エラーしました"
      error number -128
    end if
  else if boolExists = false then
log "そのままファイル生成"
    set ocidReturnFilePath to ocidArgFilePath
  end if
return ocidReturnFilePath
  
end doChkExists


|

inetlocファイルをWindowsのURLファイルに変換する


ダウンロード - inetloc2windowurlfile.zip


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

on run
  ##デスクトップ
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
  set aliasDesktopDirPath to ocidDesktopDirPathURL's absoluteURL() as alias
  ###ダイアログを前面に出す
  tell current application
    set strName to name as text
  end tell
  if strName is "osascript" then
    tell application "Finder" to activate
  else
    tell current application to activate
  end if
  set strMes to ("inetlocファイルを選んでください") as text
  set strPrompt to ("inetlocファイルを選んでください") as text
  set listUTI to {"com.apple.generic-internet-location"} as list
  set listAliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDesktopDirPath) of type listUTI with multiple selections allowed and showing package contents without invisibles) as list
open listAliasFilePath
end run


on open listAliasFilePath
  -->ドロップレットアプリケーションに書き出すとフォルダでも出来ます
  ##繰り返しのはじまり
  repeat with itemAliasFilePath in listAliasFilePath
    set aliasFilePath to itemAliasFilePath as alias
    set strFilePath to (POSIX path of aliasFilePath) as text
    set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
    set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
    set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
    ##拡張子をとって
    set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
    #↑これが保存ファイルのパスに
    ##保存ファイルパス
    set ocidSaveFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("url"))
    ##値を取得
    set ocidPlistDict to (refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL))
    set strURLvalue to (ocidPlistDict's valueForKey:("URL")) as text
    ##
    set ocidSaveStrings to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
(ocidSaveStrings's appendString:("[InternetShortcut]\r\n"))
    set strSetString to ("URL=" & strURLvalue & "\r\n") as text
(ocidSaveStrings's appendString:(strSetString))
    ##重複チェック
    set ocidDistFilePath to doChkExists(ocidSaveFilePathURL)
    set ocidDistFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDistFilePath) isDirectory:false)
    set strSaveFilePath to ocidSaveFilePathURL's |path| as text
    set strDistFilePath to ocidDistFilePathURL's |path| as text
    if strSaveFilePath is strDistFilePath then
log "置換します"
      #今あるファイルをゴミ箱に
      set appFileManager to refMe's NSFileManager's defaultManager()
      set listResult to (appFileManager's trashItemAtURL:(ocidDistFilePathURL) resultingItemURL:(ocidDistFilePathURL) |error|:(reference))
      #保存
      set listDone to (ocidSaveStrings's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
    else
      #保存
      set listDone to (ocidSaveStrings's writeToURL:(ocidDistFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
    end if
    set boolDone to (item 1 of listDone) as boolean
    if boolDone is false then
return "移動に失敗しました"
    end if
  end repeat
end open




####################################
#上書きチェック
# ocid file path = NSPathStore を返します
####################################
to doChkExists(argFilePath)
log (className() of argFilePath) as text
  if (class of argFilePath) is text then
log "テキストファイルパス"
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (class of argFilePath) is alias then
log "エリアスファイルパス"
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (class of argFilePath) is «class furl» then
log "エリアスfurlファイルパス"
    set aliasFilePath to argFilePath as alias
    set strArgFilePath to (POSIX path of argFilePath) as text
    set ocidFilePathStr to refMe's NSString's stringWithString:(argFilePath)
    set ocidArgFilePath to ocidFilePathStr's stringByStandardizingPath()
  else if (className() of argFilePath as text) contains "NSCFString" then
log "NSStringファイルパス"
    set ocidArgFilePath to argFilePath's stringByStandardizingPath()
  else if (className() of argFilePath as text) contains "NSPathStore" then
log "NSPathStore2ファイルパス"
    set ocidArgFilePath to argFilePath
  else if (className() of argFilePath as text) contains "NSURL" then
log "NSURLファイルパス"
    set ocidArgFilePath to argFilePath's |path|
  end if
  ####
  set appFileManager to refMe's NSFileManager's defaultManager()
  set boolExists to appFileManager's fileExistsAtPath:(ocidArgFilePath) isDirectory:(false)
  #
  if boolExists = true then
    ##ダイアログを前面に
    set strName to (name of current application) as text
    if strName is "osascript" then
      tell application "Finder" to activate
    else
      tell current application to activate
    end if
    set strMes to "上書きします?" as text
    try
      set objResponse to (display alert strMes buttons {"上書きする", "処理を中止する", "ファイル名を変更"} default button "上書きする" cancel button "処理を中止する" as informational giving up after 20)
    on error
log "処理を中止しました"
return "処理を中止しました"
      error number -128
    end try
    if true is equal to (gave up of objResponse) then
log "時間切れですやりなおしてください"
return "時間切れですやりなおしてください"
      error number -128
    end if
    if "上書きする" is equal to (button returned of objResponse) then
log "上書き保存します"
      set ocidReturnFilePath to ocidArgFilePath
    else if "ファイル名を変更" is equal to (button returned of objResponse) then
log "ファイル名を変更"
      set ocidContainerDirFilePath to ocidArgFilePath's stringByDeletingLastPathComponent()
      set strFileName to ocidArgFilePath's lastPathComponent() as text
      set aliasContainerDirPath to (POSIX file (ocidContainerDirFilePath as text)) as alias
      ##
      set strPromptText to "名前を決めてください" as text
      set strMesText to "名前を決めてください" as text
      ###ファイル名 ダイアログ
      set aliasFilePath to (choose file name strMesText default location aliasContainerDirPath default name strFileName with prompt strPromptText) as «class furl»
      set strFilePath to (POSIX path of aliasFilePath) as text
      set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
      set ocidReturnFilePath to ocidFilePathStr's stringByStandardizingPath()
    else if "処理を中止する" is equal to (button returned of objResponse) then
return "処理を中止しました"
    else
return "エラーしました"
      error number -128
    end if
  else if boolExists = false then
log "そのままファイル生成"
    set ocidReturnFilePath to ocidArgFilePath
  end if
return ocidReturnFilePath
  
end doChkExists

|

WEBLOCファイルからURLを取り出してクリップボードに


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application

#############################
###ダイアログ
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
############ デフォルトロケーション
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias

############UTIリスト
set listUTI to {"com.apple.web-internet-location"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
on error
log "エラーしました"
return "エラーしました"
end try


set strFilePath to (POSIX path of aliasFilePath) as text
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
##
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL)
set ocidURL to ocidPlistDict's valueForKey:("URL")


set strURL to ocidURL as text


################################
##
################################
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder"
activate
  end tell
else
  tell current application
activate
  end tell
end if
set aliasIconPath to (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ClippingText.icns") as alias
try
  set strMes to "base64テキストです" as text
  
  set recordResult to (display dialog strMes with title "bundle identifier" default answer strURL buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" cancel button "キャンセル" giving up after 20 with icon aliasIconPath without hidden answer)
on error
log "エラーしました"
return
end try

if "OK" is equal to (button returned of recordResult) then
  set strReturnedText to (text returned of recordResult) as text
else if (gave up of recordResult) is true then
return "時間切れです"
else if button returned of recordResult is "クリップボードにコピー" then
  try
    set strText to text returned of recordResult as text
    ####ペーストボード宣言
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strURL))
appPasteboard's clearContents()
    set boolDone to appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
  on error
    ##予備
    if boolDone = false then
      tell application "Finder"
        set the clipboard to strURL as text
      end tell
return "キャンセル"
    end if
  end try
end if




|

ロケーションファイルを生成する(vncを追加)

Screen

【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#【注意事項】ユーザー名パスワードを指定する場合パスワードが平文で保存されます
#そのため、ユーザー名パスワードを指定するのは非推奨です
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()

################################
##デフォルトクリップボードから
################################
##クリップボードにテキストが無い場合
set strMes to ("ロケーションファイルのURLを入力してください") as text
###初期化
set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
set ocidPastBoardTypeArray to ocidPasteboard's types
###テキストがあれば
set boolContain to ocidPastBoardTypeArray's containsObject:"public.utf8-plain-text"
if boolContain = true then
  ###値を格納する
  tell application "Finder"
    set strDefaultAnswer to (the clipboard) as text
  end tell
  ###Finderでエラーしたら
else
  set boolContain to ocidPastBoardTypeArray's containsObject:"NSStringPboardType"
  if boolContain = true then
    set ocidReadString to ocidPasteboard's readObjectsForClasses:({refMe's NSString}) options:(missing value)
    set strDefaultAnswer to ocidReadString as text
  else
    log "テキストなし"
    set strDefaultAnswer to strMes as text
  end if
end if
################################
##保存先を作っておく
################################
##作るフォルダ名
set listDirName to {"AfpLoc", "CalLoc", "FileLoc", "FtpLoc", "MailLoc", "NewsLoc", "SmbLoc", "SSHloc", "WebLoc", "TelLoc", "VncLoc", "NfsLoc"} as list
###フォルダを作る先
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidContainerDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Webloc")
##フォルダのパーミンション
set ocidAttrDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
# 777-->511 755-->493 700-->448 766-->502
(ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions))
repeat with itemDirName in listDirName
  set strDirName to itemDirName as text
  ###フォルダを作っておく
  set ocidMakeDirPathURL to (ocidContainerDirPathURL's URLByAppendingPathComponent:(strDirName))
  set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidMakeDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference))
end repeat

################################
######ダイアログ
################################
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set aliasIconPath to (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns") as alias
try
  set strMes to ("URLを入力してください\r例:\nhttps://yahoo.co.jp\nsmb://USERID:PASSWORD@192.168.0.0/Public\nafp://192.168.0.0/Public\ntel:99900001234") as text
  set recordResponse to (display dialog strMes with title "URLを入力してください" default answer strDefaultAnswer buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 20 without hidden answer)
on error
  log "エラーしました"
return "エラーしました"
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
end if
if "OK" is equal to (button returned of recordResponse) then
  set strResponse to (text returned of recordResponse) as text
else
  log "キャンセルしました"
return "キャンセルしました"
end if
################################
###スキームチェック
################################
if strResponse starts with "http" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "afp" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "smb" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "cifs" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "webcal" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "ical" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "file" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "/" then
  set ocidFilePathStr to refMe's NSString's stringWithString:(strResponse)
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
  set strURL to ocidFilePathURL's absoluteString() as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "ftp" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "mail" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "news" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "ssh" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "tel" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "vnc" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else if strResponse starts with "nfs" then
  set strURL to strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
else
  ##ダイアログにスキーム無しだった場合
  set listScheme to {"https", "afp", "smb", "cifs", "webcal", "ical", "file", "ftp", "mail", "tel", "news", "ssh", "vnc", "nfs"} as list
  ###ダイアログ
  set strName to (name of current application) as text
  if strName is "osascript" then
    tell application "Finder" to activate
  else
    tell current application to activate
  end if
  try
    set listResponse to (choose from list listScheme with title "選んでください" with prompt "スキームを選んでください" default items (item 1 of listScheme) OK button name "OK" cancel button name "キャンセル" without multiple selections allowed and empty selection allowed) as list
  on error
    log "エラーしました"
return "エラーしました"
  end try
  if (item 1 of listResponse) is false then
return "キャンセルしました"
  end if
  set strURL to (item 1 of listResponse) & "://" & strResponse as text
  set strExtensionName to doScheme2ExtensionName(strURL) as text
end if

################################
###本処理
################################
###タブと改行の除去
set ocidURL to refMe's NSString's stringWithString:(strURL)
set ocidURLM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
ocidURLM's appendString:(ocidURL)
##行末の改行
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\n") withString:("")
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\r") withString:("")
##タブ除去
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\t") withString:("")
##URLに
set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLM)
##NSURLComponents
set ocidURLComponents to refMe's NSURLComponents's componentsWithURL:(ocidURL) resolvingAgainstBaseURL:(true)
##PLISTに必要な値の取り出し
set strScheme to ocidURLComponents's |scheme|() as text
set ocidHostName to ocidURLComponents's |host|()
if ocidHostName = (missing value) then
  set ocidPath to ocidURLComponents's |path|()
  if ocidPath = (missing value) then
    set strBaseFileName to ocidPath as text
  else
    set strBaseFileName to doGetDateNo("yyyyMMdd") as text
  end if
else
  set strBaseFileName to ocidHostName as text
end if
set ocidURLStr to ocidURL's absoluteString()
##############################
## 保存先ディレクトリ
##スキームとフォルダの関連付けレコード
set recordDirName to {afp:"AfpLoc", ical:"CalLoc", webcal:"CalLoc", |file|:"FileLoc", ftp:"FtpLoc", mail:"MailLoc", news:"NewsLoc", smb:"SmbLoc", cifs:"SmbLoc", ssh:"SSHloc", https:"WebLoc", tel:"TelLoc", vnc:"VncLoc", nfs:"NfsLoc"} as record
#ディレクトリ名を取得して
set ocidDirDictionary to refMe's NSMutableDictionary's dictionaryWithDictionary:(recordDirName)
set strDirName to ocidDirDictionary's valueForKey:(strScheme)
##ファイルの保存先
set ocidSaveDirPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:(strDirName)
set ocidBaseFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strBaseFileName)
set ocidSaveFilePathURL to ocidBaseFilePathURL's URLByAppendingPathExtension:(strExtensionName)
log ocidSaveFilePathURL's |path| as text

###Finder 用のエイリアス
set aliasSaveDirPath to (ocidSaveDirPathURL's absoluteURL()) as alias

#########################
##############################
## PLIST maillocを作成
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidPlistDict's setValue:(ocidURLStr) forKey:"URL"
set strDateno to doGetDateNo("yyyyMMdd")
ocidPlistDict's setValue:(strDateno) forKey:("version")
ocidPlistDict's setValue:(strDateno) forKey:("productVersion")
##これは自分用
ocidPlistDict's setValue:(strDateno) forKey:("kMDItemFSCreationDate")
#########################
####weblocファイルを作る
set ocidFromat to refMe's NSPropertyListXMLFormat_v1_0
set listPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidPlistDict) format:(ocidFromat) options:0 |error|:(reference)
set ocidPlistData to item 1 of listPlistEditDataArray
set boolWritetoUrlArray to ocidPlistData's writeToURL:(ocidSaveFilePathURL) options:0 |error|:(reference)
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
#########################
#### WINDOWS用のURLファイル
set ocidSaveFilePathURL to ocidBaseFilePathURL's URLByAppendingPathExtension:("url")
set ocidFileContent to refMe's NSMutableString's stringWithCapacity:0
set strContents to ("[InternetShortcut]\r\nURL=" & ocidURLStr & "\r\n") as text
ocidFileContent's setString:(strContents)
set listDone to ocidFileContent's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference)


################################
####保存先を開く
################################
tell application "Finder"
  
  set refNewWindow to make new Finder window
  tell refNewWindow
    set position to {10, 30}
    set bounds to {10, 30, 720, 480}
  end tell
  set target of refNewWindow to aliasSaveDirPath
  set selection to aliasSaveFilePath
end tell

################################
####バージョンで使う日付
################################
to doGetDateNo(strDateFormat)
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
ocidNSDateFormatter's setDateFormat:strDateFormat
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo

################################
###スキームから拡張子
################################
to doScheme2ExtensionName(argScheme)
  set strResponse to argScheme as text
  if strResponse starts with "http" then
    set strExtensionName to ("webloc") as text
  else if strResponse starts with "afp" then
    set strExtensionName to ("afploc") as text
  else if strResponse starts with "smb" then
    set strExtensionName to ("inetloc") as text
  else if strResponse starts with "cifs" then
    set strExtensionName to ("inetloc") as text
  else if strResponse starts with "webcal" then
    set strExtensionName to ("inetloc") as text
  else if strResponse starts with "ical" then
    set strExtensionName to ("inetloc") as text
  else if strResponse starts with "file" then
    set strExtensionName to ("fileloc") as text
  else if strResponse starts with "ftp" then
    set strExtensionName to ("ftploc") as text
  else if strResponse starts with "mail" then
    set strExtensionName to ("mailloc") as text
  else if strResponse starts with "news" then
    set strExtensionName to ("newsloc") as text
  else if strResponse starts with "ssh" then
    set strExtensionName to ("inetloc") as text
  else if strResponse starts with "vnc" then
    set strExtensionName to ("vncloc") as text
  else if strResponse starts with "nfs" then
    set strExtensionName to ("inetloc") as text
  else
    set strExtensionName to ("inetloc") as text
  end if
return strExtensionName
end doScheme2ExtensionName





|

[webloc]URLをクリップボードにコピー(ドロップレット)


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
# weblocファイルのURLをコピーします
# com.cocolog-nifty.quicktimer.icefloe
----+----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
property listUTI : {"com.apple.web-internet-location"} as list
property strUTI : "com.apple.web-internet-location"

###Wクリックで起動した場合
on run
  #############################
  ###ダイアログ
  tell current application
    set strName to name as text
  end tell
  ####スクリプトメニューから実行したら
  if strName is "osascript" then
    tell application "Finder" to activate
  else
    tell current application to activate
  end if
  ############ デフォルトロケーション
  set appFileManager to refMe's NSFileManager's defaultManager()
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
  set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
  ############UTIリスト
  set listUTI to {"com.apple.web-internet-location"}
  
  set strMes to ("ファイルを選んでください") as text
  set strPrompt to ("ファイルを選んでください") as text
  try
    ### ファイル選択時
    set aliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
  on error
    log "エラーしました"
return "エラーしました"
  end try
open alias aliasFilePath
end run


###ドロップで起動した場合
on open aliasFilePath
  set aliasFilePath to aliasFilePath as alias
  set strFilePath to (POSIX path of aliasFilePath) as text
  set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
  ####UTIの取得
  set listResourceValue to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error|:(reference))
  set ocidContentType to (item 2 of listResourceValue)
  set strFileUTI to (ocidContentType's identifier) as text
  ###
  if strFileUTI is strUTI then
    set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithContentsOfURL:(ocidFilePathURL)
    set ocidURL to ocidPlistDict's valueForKey:("URL")
    set strText to (ocidURL) as text
    try
      ####ペーストボード宣言
      set appPasteboard to refMe's NSPasteboard's generalPasteboard()
      set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
    on error
      tell application "Finder"
        set the clipboard to strText as text
      end tell
    end try
  else
return "処理終了"
  end if
end open






|

[inetloc] カレンダーサーバーに対してのリンクファイルを作る(webcal)

Screen_20230911_19_14_34

【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#【注意事項】ユーザー名パスワードを指定する場合パスワードが平文で保存されます
#そのため、ユーザー名パスワードを指定するのは非推奨です
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


##デフォルトクリップボードから
set ocidPasteboard to refMe's NSPasteboard's generalPasteboard()
set ocidPasteboardArray to ocidPasteboard's readObjectsForClasses:({refMe's NSString}) options:(missing value)
try
  set ocidPasteboardStrings to (ocidPasteboardArray's objectAtIndex:0) as text
on error
  set ocidPasteboardStrings to "" as text
end try
set strDefaultAnswer to ocidPasteboardStrings as text
if strDefaultAnswer starts with "ical:" then
  set strURL to strDefaultAnswer as text
else if strDefaultAnswer starts with "webcal:" then
  set strURL to strDefaultAnswer as text
else if strDefaultAnswer starts with "https:" then
  ###タブと改行の除去
  set ocidDefaultAnswer to refMe's NSString's stringWithString:(strDefaultAnswer)
  set ocidDefaultAnswerM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
ocidDefaultAnswerM's appendString:(ocidDefaultAnswer)
  ##行末の改行
  set ocidDefaultAnswer to ocidDefaultAnswerM's stringByReplacingOccurrencesOfString:("https:") withString:("webcal:")
  set strURL to ocidDefaultAnswer as text
else
  set strURL to ("webcal://") as text
end if


################################
######ダイアログ
################################
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set aliasIconPath to (POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns") as alias
try
  set strMes to ("iCalサーバーのURLを入力してください\n例:\nwebcal://guest:guest@foo.hoge.com/MyCalender.ics\nical://USERID:PASSWORD@192.168.0.0/MyCalender.ics") as text
  
  set recordResponse to (display dialog strMes with title "カレンダーのURLを入力してください" default answer strURL buttons {"OK", "キャンセル"} default button "OK" cancel button "キャンセル" with icon aliasIconPath giving up after 20 without hidden answer)
on error
  log "エラーしました"
return "エラーしました"
end try
if true is equal to (gave up of recordResponse) then
return "時間切れですやりなおしてください"
end if
if "OK" is equal to (button returned of recordResponse) then
  set strResponse to (text returned of recordResponse) as text
else
  log "キャンセルしました"
return "キャンセルしました"
end if

if strResponse starts with "ical:" then
  set strURL to strResponse as text
else if strResponse starts with "webcal:" then
  set strURL to strResponse as text
else if strResponse starts with "https:" then
  ###タブと改行の除去
  set ocidResponse to refMe's NSString's stringWithString:(strResponse)
  set ocidResponseM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
ocidResponseM's appendString:(ocidResponse)
  ##行末の改行
  set ocidResponse to ocidResponseM's stringByReplacingOccurrencesOfString:("https:") withString:("webcal:")
  set strURL to ocidResponse as text
else
return "カレンダーのURL専用です"
end if

###タブと改行の除去
set ocidURL to refMe's NSString's stringWithString:(strURL)
set ocidURLM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
ocidURLM's appendString:(ocidURL)
##行末の改行
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\n") withString:("")
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\r") withString:("")
##タブ除去
set ocidURLM to ocidURLM's stringByReplacingOccurrencesOfString:("\t") withString:("")

set ocidURL to refMe's NSURL's alloc()'s initWithString:(ocidURLM)
set ocidURLStr to ocidURL's absoluteString()
set ocidHostName to ocidURL's |host|() as text

##ファイル名
set strFileName to (ocidHostName & ".inetloc") as text

##############################
## 保存先ディレクトリ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDocumentDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDocumentDirPathURL to ocidURLsArray's firstObject()
set ocidSaveDirPathURL to ocidDocumentDirPathURL's URLByAppendingPathComponent:("Apple/Webloc/iCal/") isDirectory:(true)
##ディレクトリ作成
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
# 777-->511 755-->493 700-->448 766-->502
ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
###保存ファイルURL
set ocidSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(strFileName) isDirectory:(false)
###Finder 用のエイリアス
set aliasSaveDirPath to (ocidSaveDirPathURL's absoluteURL()) as alias
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as «class furl»
#########################
##############################
## PLIST maillocを作成
set ocidPlistDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidPlistDict's setValue:(ocidURLStr) forKey:"URL"
set strDateno to doGetDateNo("yyyyMMdd")
ocidPlistDict's setValue:(strDateno) forKey:("version")
ocidPlistDict's setValue:(strDateno) forKey:("productVersion")
##これは自分用
ocidPlistDict's setValue:(strDateno) forKey:("kMDItemFSCreationDate")
#########################
####weblocファイルを作る
set ocidFromat to refMe's NSPropertyListXMLFormat_v1_0
set listPlistEditDataArray to refMe's NSPropertyListSerialization's dataWithPropertyList:(ocidPlistDict) format:(ocidFromat) options:0 |error|:(reference)
set ocidPlistData to item 1 of listPlistEditDataArray
set boolWritetoUrlArray to ocidPlistData's writeToURL:(ocidSaveFilePathURL) options:0 |error|:(reference)
(*
tell application "Finder"
make new internet location file to strURL at aliasSaveDirPathURL with properties {name:"" & strName & "", creator type:"MACS", stationery:false, location:strURL}
end tell
*)
#########################

####保存先を開く
tell application "Finder"
  set aliasSaveFile to (file strFileName of folder aliasSaveDirPath) as alias
  set refNewWindow to make new Finder window
  tell refNewWindow
    set position to {10, 30}
    set bounds to {10, 30, 720, 480}
  end tell
  set target of refNewWindow to aliasSaveDirPath
  set selection to aliasSaveFile
end tell

#########################
####バージョンで使う日付
to doGetDateNo(strDateFormat)
  ####日付情報の取得
  set ocidDate to current application's NSDate's |date|()
  ###日付のフォーマットを定義
  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
ocidNSDateFormatter's setDateFormat:strDateFormat
  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
  set strDateAndTime to ocidDateAndTime as text
return strDateAndTime
end doGetDateNo






|

より以前の記事一覧

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat Dialog Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Stamps Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin System Information Admin Tools Admin Users Admin Volumes Adobe Apple AppleScript AppleScript Guide AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript eMail AppleScript Encode Decode AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript HTML AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim Applescript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mobileconfig AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFont AppleScript NSFontManager AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSPDFImageRep AppleScript NSpoint AppleScript NSPredicate AppleScript NSRange AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photos AppleScript Photoshop AppleScript Plist System Events AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sort AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript System Events AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript YouTube AppleScript Zero Suppress Applications Barcode OnLine Tools CityCode Design iPhone List Logs lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom zoom