[Fonts]フォントデータコピー(MORI)
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
property refNSString : a reference to refMe's NSString
property refNSData : a reference to refMe's NSData
property refNSURL : a reference to refMe's NSURL
property refNSMutableArray : a reference to refMe's NSMutableArray
property refNSDictionary : a reference to refMe's NSDictionary
property refNSMutableDictionary : a reference to refMe's NSMutableDictionary
property refNSDate : a reference to refMe's NSDate
property refNSCalendar : a reference to refMe's NSCalendar
property refNSTimeZone : a reference to refMe's NSTimeZone
property refNSDateFormatter : a reference to NSDateFormatter
property refNSJSONSerialization : a reference to refMe's NSJSONSerialization
####exiftoolへのパス
set strExifPath to "$HOME/bin/exiftool/exiftool"
####フォントファイルの書き出し先
set strExportDir to do shell script "echo $HOME/Desktop/MorisawaFontsFile"
set theCommandText to ("mkdir -p " & strExportDir & "") as text
do shell script theCommandText
##set strFontsDir to
###まずはフォントのダウンロード先を探します
set objFileManager to refMe's NSFileManager's defaultManager()
###ApplicationSupport
set ocidApplicationSupportPath to (objFileManager's URLsForDirectory:(refMe's NSApplicationSupportDirectory) inDomains:(refMe's NSSystemDomainMask))
####戻り値リストなので値を取ります
set ocidApplicationSupportPath to ocidApplicationSupportPath's objectAtIndex:0
####モリサワデスクトップ
set ocidMorisawaPath to ocidApplicationSupportPath's URLByAppendingPathComponent:"Morisawa/Morisawa Desktop Manager/"
set strMorisawaDirPath to ocidMorisawaPath's |path|() as text
####最下層までパスを取得
##set arrayPathList to objFileManager's subpathsAtPath: strMorisawaDirPath
##log arrayPathList as list
set listPathList to objFileManager's subpathsOfDirectoryAtPath:strMorisawaDirPath |error|:(reference)
set arrayPathList to item 1 of listPathList as list
####取得したパスだけ々
repeat with objPathList in arrayPathList
set strPathList to objPathList as text
####拡張子にフォント系が含まれていれば
if strPathList ends with ".otf" then
###フルパスを作成して
set ocidFontFilePath to (ocidMorisawaPath's URLByAppendingPathComponent:strPathList)
set strFontFilePath to ocidFontFilePath's |path|() as text
log strFontFilePath
set strDateNo to doGetDateNo("yyyyMMddhhmmss")
set strJsonFileName to (strDateNo & ".json")
set strCommandText to "/bin/mkdir -pm 777 /tmp/" & strDateNo & "" as text
do shell script strCommandText
###exif情報を取得します
set theCommandText to ("" & strExifPath & " -json \"" & strFontFilePath & "\" > \"/tmp/" & strDateNo & "/" & strJsonFileName & "\"") as text
do shell script theCommandText
set strJsonPath to "/tmp/" & strDateNo & "/" & strJsonFileName & ""
####JSONファイルをURLにして
set ocidJsonFilePath to (refNSString's stringWithString:strJsonPath)
set ocidJsonFilePathURL to (refNSURL's alloc()'s initFileURLWithPath:ocidJsonFilePath)
log ocidJsonFilePathURL as text
####データとして読み込みます
set listDataContants to (refNSData's dataWithContentsOfURL:ocidJsonFilePathURL options:0 |error|:(reference))
set ocidReadData to item 1 of listDataContants
(*
NSDataReadingMappedIfSafe:0
NSDataReadingUncached:1
NSDataReadingMappedAlways:3
*)
####データをJSONとしてレコードに変換
set listJSONSerialization to (refNSJSONSerialization's JSONObjectWithData:ocidReadData options:0 |error|:(reference))
(*
NSJSONReadingMutableContainers:0
NSJSONReadingMutableLeaves1:
NSJSONReadingFragmentsAllowed2:
NSJSONReadingJSON5Allowed:3
NSJSONReadingTopLevelDictionaryAssume:4
*)
####レコードを取得します
set ocidJsonData to item 1 of listJSONSerialization
-->(*__NSSingleObjectArrayI*)
set ocidJsonDict to (item 1 of ocidJsonData)
-->(*__NSDictionaryI*)
####レコードをNSDictionaryとして格納
set ocidJsonResponse to (refNSDictionary's alloc()'s initWithDictionary:ocidJsonDict)
####JSONの全てのキーを取得して
set ocidAllKeys to ocidJsonResponse's allKeys()
####キーの種類だけ繰り返し
repeat with objKey in ocidAllKeys
####キーの値を取り出し
set ocidValue to (ocidJsonResponse's valueForKey:(objKey as text))
log "" & (objKey as text) & " : " & (ocidValue as text)
###フォント名を取得
set ocidFontName to (ocidJsonResponse's valueForKey:"FontName-ja")
if ocidFontName is (missing value) then
set ocidFontName to (ocidJsonResponse's valueForKey:"FontName")
end if
end repeat
##フォント名で書き出し先パスを作成して
set strExportFilePath to "" & strExportDir & "/" & ocidFontName & ".otf" as text
####コピー
set boolFileCopy to (objFileManager's copyItemAtPath:strFontFilePath toPath:strExportFilePath |error|:(reference))
end if
delay 1
end repeat
to doGetDateNo(strDateFormat)
####日付情報の取得
set ocidDate to refNSDate's |date|()
###日付のフォーマットを定義
set ocidNSDateFormatter to refNSDateFormatter's alloc()'s init()
ocidNSDateFormatter's setLocale:(refMe'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
| 固定リンク
「Fonts」カテゴリの記事
- FontCommandLineToolsの実行支援スクリプト(2025.01.08)
- [FontBook]起動項目用スクリプト(アプリケーション)ちょっと修正(2025.01.07)
- [macOS15.2]Asset_Font7 Asset_Font6フォント比較(バージョン入り)(2024.12.14)
- [macOS15.2]Asset_Font7 Asset_Font6フォント比較(サイズと更新日のみ)(2024.12.14)
- [macOS15.2]Asset_Font7(2024.12.14)