« [Fonts]フォントデータコピー(MORI) | トップページ | [FONT]文字イメージ作成(途中) »

[Fonts]フォントデータコピー(Kit)

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
# フォントファイルをリネームします
# フォントファイルをexifデータの『FontName-ja』でリネームします
# FontName-jaが設定されていない場合は『FontName』でリネームします
#
####設定項目

set theExifPath to "$HOME/bin/exiftool/exiftool"

#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7

use AppleScript version "2.8"
use framework "Foundation"
use scripting additions


set theDefDir to (do shell script "echo $HOME/Library/Application Support/Adobe/CoreSync/plugins/livetype") as text
set aliasDefDir to POSIX file theDefDir


tell application "Finder"
set listChooseFile to (choose file with prompt "フォントファイルを選んでください" default location aliasDefDir with invisibles and multiple selections allowed without showing package contents) as list
end tell


set theCommandText to ("date '+%Y%m%d_%H%M%S'") as text
set theDate to (do shell script theCommandText) as text

set theCommandText to ("mkdir -p /tmp/" & theDate & "") as text
do shell script theCommandText

set theCommandText to ("mkdir -p $HOME/Desktop/AdobeFontFile") as text
do shell script theCommandText


repeat with objFile in listChooseFile
set theFilePath to POSIX path of objFile as text
tell application "Finder"
set objInfo to info for objFile
set theFileName to name of objInfo
set theExeName to name extension of objInfo
set theNewFileName to the characters 2 thru (number of characters of theFileName) of theFileName as text
end tell


try
set theCommandText to ("\"" & theExifPath & "\" -json \"" & theFilePath & "\" > \"/tmp/" & theDate & "/" & theFileName & ".json\"") as text
do shell script theCommandText
end try
try
set theCommandText to ("/usr/bin/plutil -convert xml1 \"/tmp/" & theDate & "/" & theFileName & ".json\" -o \"/tmp/" & theDate & "/" & theFileName & ".exif.plist\"") as text
do shell script theCommandText
end try
try
set theCommandText to ("cat \"/tmp/" & theDate & "/" & theFileName & ".exif.plist\"") as text
set theReadExifPlist to (do shell script theCommandText) as text
end try

try
set theReadExifPlist to doReplace(theReadExifPlist, "<array>\r", "")
set theReadExifPlist to doReplace(theReadExifPlist, "</array>\r", "")
set theReadExifPlist to doReplace(theReadExifPlist, "\"", "\\\"")
end try

try
set theCommandText to ("echo \"" & theReadExifPlist & "\" > \"/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist\"") as text
do shell script theCommandText
end try

if theExeName is missing value then
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theExeName to (value of property list item "FileType") as Unicode text
end tell
end tell
else if theExeName is "" then
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theExeName to (value of property list item "FileType") as Unicode text
end tell
end tell
end if

set theFontFileName to ""
try
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theFontFileName to (value of property list item "FontName") as Unicode text
end tell
end tell
on error
try
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theFontFileName to (value of property list item "FontName-en-US") as Unicode text
end tell
end tell
on error
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theFontFileName to (value of property list item "FontName-ja") as Unicode text
end tell
end tell
try
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theFontFileName to (value of property list item "FontName") as Unicode text
end tell
end tell
on error
try
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theFontFileName to (value of property list item "PostScriptFontName-en-US") as Unicode text
end tell
end tell

on error
try
tell application "System Events"
tell property list file ("/tmp/" & theDate & "/" & theNewFileName & ".Exif.plist")
set theFontFileName to (value of property list item "PostScriptFontName") as Unicode text
end tell
end tell

end try
end try
end try
end try
end try

set theCommandText to ("mv \"" & theFilePath & "\" \"$HOME/Desktop/AdobeFontFile/" & theFontFileName & "." & theExeName & "\"") as Unicode text
do shell script theCommandText


end repeat


to doReplace(theText, orgStr, newstr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newstr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace



display notification "処理終了" with title "処理が終了" subtitle "処理が終了しました" sound name "Sonumi"
log ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"
return ">>>>>>>>>>>>処理終了<<<<<<<<<<<<<<<"

|

« [Fonts]フォントデータコピー(MORI) | トップページ | [FONT]文字イメージ作成(途中) »

AppleScript Fonts」カテゴリの記事