AppleScript VisionKit

[OCR] 画像ファイルのOCR (ドロップレット)


あくまでも参考にしてください

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

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#Automator用のをドロップレットにしました
004# スクリプトエディタで開く
005# ファイル>別名で保存>アプリケーション で保存してください
006# OCRの結果は上書きされます
007#com.cocolog-nifty.quicktimer.icefloe
008----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
009use AppleScript version "2.8"
010use framework "Foundation"
011use framework "AppKit"
012use framework "UniformTypeIdentifiers"
013use framework "CoreImage"
014use framework "VisionKit"
015use framework "Vision"
016use scripting additions
017property refMe : a reference to current application
018property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
019
020##Wクリックで開いたら
021on run
022  #デスクトップ
023  set appFileManager to refMe's NSFileManager's defaultManager()
024  set ocidUserDesktopPathURLArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
025  set ocidUserDesktopPathURL to ocidUserDesktopPathURLArray's firstObject()
026  set aliasUserDesktopPath to (ocidUserDesktopPathURL's absoluteURL()) as alias
027  #ダイアログを前面に出す
028  set strName to (name of current application) as text
029  if strName is "osascript" then
030    tell application "Finder" to activate
031  else
032    tell current application to activate
033  end if
034  set listUTl to {"public.image"} as list
035  set strPromptText to "ファイルを選んでください" as text
036  set strMesText to "ファイルを選んでください" as text
037  set listAliasFilePath to (choose file strMesText with prompt strPromptText default location (aliasUserDesktopPath) of type listUTl with invisibles and multiple selections allowed without showing package contents) as list
038  #Openに渡す
039  open listAliasFilePath
040  
041end run
042
043
044to open listAliasFilePath
045  #ファイルの数だけ繰り返す
046  repeat with argAliasFilePath in listAliasFilePath
047    ##入力ファイル
048    set strFilePath to (POSIX path of argAliasFilePath) as text
049    set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
050    set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
051    set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
052    ###########################
053    #データの読み込み
054    ###########################
055    set ocidOption to (refMe's NSDataReadingMappedIfSafe)
056    set listResponse to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference))
057    if (item 2 of listResponse) ≠ (missing value) then
058      log (item 2 of listReadStings)'s localizedDescription() as text
059      return "データの読み込みに失敗しました"
060    else
061      set ocidReadData to (item 1 of listResponse)
062    end if
063    ##NSImage
064    set ocidReadImage to (refMe's NSImage's alloc()'s initWithData:(ocidReadData))
065    set ocidImageRepArray to ocidReadImage's representations()
066    set ocidImageRep to ocidImageRepArray's firstObject()
067    set ocidPxSizeH to ocidImageRep's pixelsHigh()
068    #とっとと解放
069    set ocidImageRepArray to ""
070    set ocidImageRep to ""
071    
072    ###########################
073    #OCR
074    ###########################
075    #OCR結果ファイル保存先
076    set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
077    set ocidSaveTextFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("txt"))
078    #最小文字サイズ
079    set numMinPt to 8 as integer
080    #####ImageRep画像の高さを取得
081    ##画像に対しての8Ptテキストの比率--> MinimumTextHeightにセットする
082    set intTextHeight to (numMinPt / ocidPxSizeH) as number
083    #####OCR
084    #VNImageRequestHandler's
085    set ocidHandler to (refMe's VNImageRequestHandler's alloc()'s initWithData:(ocidReadData) options:(missing value))
086    #VNRecognizeTextRequest's
087    set ocidRequest to refMe's VNRecognizeTextRequest's alloc()'s init()
088    set ocidOption to (refMe's VNRequestTextRecognitionLevelAccurate)
089    (ocidRequest's setRecognitionLevel:(ocidOption))
090    (ocidRequest's setMinimumTextHeight:(intTextHeight))
091    (ocidRequest's setAutomaticallyDetectsLanguage:(true))
092    (ocidRequest's setRecognitionLanguages:{"en", "ja"})
093    (ocidRequest's setUsesLanguageCorrection:(false))
094    #results
095    (ocidHandler's performRequests:(refMe's NSArray's arrayWithObject:(ocidRequest)) |error| :(reference))
096    set ocidResponseArray to ocidRequest's results()
097    #戻り値を格納するテキスト
098    set ocidFirstOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
099    set ocidSecondOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
100    set ocidSaveString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
101    #戻り値の数だけ々
102    repeat with itemArray in ocidResponseArray
103      #候補数指定 1−10 ここでは2種の候補を戻す指定
104      set ocidRecognizedTextArray to (itemArray's topCandidates:(2))
105      set ocidFirstOpinion to ocidRecognizedTextArray's firstObject()
106      set ocidSecondOpinion to ocidRecognizedTextArray's lastObject()
107      (ocidFirstOpinionString's appendString:(ocidFirstOpinion's |string|()))
108      (ocidFirstOpinionString's appendString:("\n"))
109      (ocidSecondOpinionString's appendString:(ocidSecondOpinion's |string|()))
110      (ocidSecondOpinionString's appendString:("\n"))
111    end repeat
112    ##比較して相違点を探すならここで
113    (ocidSaveString's appendString:("-----第1候補\n\n"))
114    (ocidSaveString's appendString:(ocidFirstOpinionString))
115    (ocidSaveString's appendString:("\n\n-----第2候補\n\n"))
116    (ocidSaveString's appendString:(ocidSecondOpinionString))
117    ###保存
118    set listDone to (ocidSaveString's writeToURL:(ocidSaveTextFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference))
119    if (item 1 of listDone) is true then
120      log "正常終了"
121    else if (item 1 of listDone) is false then
122      log (item 2 of listDone)'s localizedDescription() as text
123      return display alert "  保存に失敗しました"
124    end if
125    #解放
126    set ocidSaveString to ""
127    set ocidReadImage to ""
128    set ocidNSInlineData to ""
129    set ocidReadData to ""
130  end repeat
131  
132end open
133
134################################
135# 日付 doGetDateNo()
136################################
137to doGetDateNo(strDateFormat)
138  ####日付情報の取得
139  set ocidDate to current application's NSDate's |date|()
140  ###日付のフォーマットを定義
141  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
142  ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
143  ocidNSDateFormatter's setDateFormat:strDateFormat
144  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
145  set strDateAndTime to ocidDateAndTime as text
146  return strDateAndTime
147end doGetDateNo
148
AppleScriptで生成しました

|

[OCR] 画像ファイルのリネーム+OCR同時処理(スクリーンキャプチャー用 ドロップレット版 解像度変更リサイズは行わないタイプ)


あくまでも参考にしてください

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

サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#Automator用のをドロップレットにしました
004# スクリプトエディタで開く
005# ファイル>別名で保存>アプリケーション で保存してください
006(*
007【注意】【注意】【注意】【注意】【注意】【注意】【注意】【注意】
008画像ファイル名のリネームも行います
009ファイル名変えたくない場合は
010こちら
011https://quicktimer.cocolog-nifty.com/icefloe/2024/04/post-f6c70f.html
012*)
013#com.cocolog-nifty.quicktimer.icefloe
014----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
015use AppleScript version "2.8"
016use framework "Foundation"
017use framework "AppKit"
018use framework "UniformTypeIdentifiers"
019use framework "CoreImage"
020use framework "VisionKit"
021use framework "Vision"
022use scripting additions
023property refMe : a reference to current application
024property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
025
026##Wクリックで開いたら
027on run
028  #デスクトップ
029  set appFileManager to refMe's NSFileManager's defaultManager()
030  set ocidUserDesktopPathURLArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
031  set ocidUserDesktopPathURL to ocidUserDesktopPathURLArray's firstObject()
032  set aliasUserDesktopPath to (ocidUserDesktopPathURL's absoluteURL()) as alias
033  #ダイアログを前面に出す
034  set strName to (name of current application) as text
035  if strName is "osascript" then
036    tell application "Finder" to activate
037  else
038    tell current application to activate
039  end if
040  set listUTl to {"public.image"} as list
041  set strPromptText to "ファイルを選んでください" as text
042  set strMesText to "ファイルを選んでください" as text
043  set listAliasFilePath to (choose file strMesText with prompt strPromptText default location (aliasUserDesktopPath) of type listUTl with invisibles and multiple selections allowed without showing package contents) as list
044  #Openに渡す
045  open listAliasFilePath
046  
047end run
048
049
050to open listAliasFilePath
051  #ファイルの数だけ繰り返す
052  repeat with argAliasFilePath in listAliasFilePath
053    ##入力ファイル
054    set strFilePath to (POSIX path of argAliasFilePath) as text
055    set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
056    set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
057    set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
058    #対象判定
059    set listResponse to (ocidFilePathURL's getResourceValue:(reference) forKey:(refMe's NSURLContentTypeKey) |error| :(reference))
060    if (item 3 of listResponse) ≠ (missing value) then
061      log (item 3 of listResponse)'s localizedDescription() as text
062      return "リソース読み込みに失敗しました"
063    else if (item 1 of listResponse) is true then
064      set ocidContentType to (item 2 of listResponse)
065      set ocidUTI to ocidContentType's identifier()
066    end if
067    set listOkUTI to {"public.image", "public.png", "public.jpeg", "public.tiff", "com.compuserve.gif"} as list
068    set ocidOkUTIArray to (refMe's NSArray's arrayWithArray:(listOkUTI))
069    set boolContain to (ocidOkUTIArray's containsObject:(ocidUTI))
070    if boolContain is false then
071      display alert "対象外のファイルです画像ファイル専用です\n処理を終了します"
072      log "対象外のファイルです画像ファイル専用です"
073      exit repeat
074    end if
075    
076    #拡張子
077    set ocidExtensionName to ocidFilePathURL's pathExtension()
078    ###########################
079    #データの読み込み
080    ###########################
081    set ocidOption to (refMe's NSDataReadingMappedIfSafe)
082    set listResponse to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference))
083    if (item 2 of listResponse) ≠ (missing value) then
084      log (item 2 of listReadStings)'s localizedDescription() as text
085      return "データの読み込みに失敗しました"
086    else
087      set ocidReadData to (item 1 of listResponse)
088    end if
089    ##NSImage
090    set ocidReadImage to (refMe's NSImage's alloc()'s initWithData:(ocidReadData))
091    set ocidImageRepArray to ocidReadImage's representations()
092    set ocidImageRep to ocidImageRepArray's firstObject()
093    
094    ###########################
095    #リネーム 日付時間+解像度
096    ###########################
097    #日付時間ファイル名
098    set strDateNo to doGetDateNo("yyyyMMdd_hhmmss")
099    #ピクセルサイズ
100    # set ocidImageRepArray to (refMe's NSImageRep's imageRepsWithContentsOfURL:(ocidFilePathURL))
101    # set ocidImageRep to ocidImageRepArray's firstObject()
102    #PtSize
103    set ocidImageSize to ocidImageRep's |size|()
104    set ocidPtSizeW to ocidImageSize's width()
105    set ocidPtSizeH to ocidImageSize's height()
106    #PxSize
107    set ocidPxSizeW to ocidImageRep's pixelsWide()
108    set ocidPxSizeH to ocidImageRep's pixelsHigh()
109    set numResolution to (ocidPxSizeH / ocidPtSizeH) as integer
110    #とっとと解放
111    set ocidImageRepArray to ""
112    set ocidImageRep to ""
113    #解像度による分岐
114    if numResolution > 1 then
115      set strNewFileName to (strDateNo & "-" & ocidPtSizeW & "x" & ocidPtSizeH & "@" & numResolution & "x") as text
116    else
117      set strNewFileName to (strDateNo & "-" & ocidPxSizeW & "" & ocidPxSizeH) as text
118    end if
119    #リネーム先
120    set ocidContainerDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
121    set ocidBaseFilePathURL to (ocidContainerDirPathURL's URLByAppendingPathComponent:(strNewFileName) isDirectory:(false))
122    set ocidSaveFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:(ocidExtensionName))
123    #移動リネーム
124    set appFileManager to refMe's NSFileManager's defaultManager()
125    set listDone to (appFileManager's moveItemAtURL:(ocidFilePathURL) toURL:(ocidSaveFilePathURL) |error| :(reference))
126    if (item 1 of listDone) is true then
127      log "リネームしました"
128    else if (item 2 of listDone) ≠ (missing value) then
129      set strLog to ((item 2 of listDone)'s localizedDescription()) as text
130      return display alert "リネームに失敗しました\n" & strLog & "\n" & strFilePath
131    end if
132    
133    ###########################
134    #OCR
135    ###########################
136    #OCR結果ファイル保存先
137    set ocidSaveTextFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("txt"))
138    #最小文字サイズ
139    set numMinPt to 8 as integer
140    #####ImageRep画像の高さを取得
141    ##画像に対しての8Ptテキストの比率--> MinimumTextHeightにセットする
142    set intTextHeight to (numMinPt / ocidPxSizeH) as number
143    #####OCR
144    #VNImageRequestHandler's
145    set ocidHandler to (refMe's VNImageRequestHandler's alloc()'s initWithData:(ocidReadData) options:(missing value))
146    #VNRecognizeTextRequest's
147    set ocidRequest to refMe's VNRecognizeTextRequest's alloc()'s init()
148    set ocidOption to (refMe's VNRequestTextRecognitionLevelAccurate)
149    (ocidRequest's setRecognitionLevel:(ocidOption))
150    (ocidRequest's setMinimumTextHeight:(intTextHeight))
151    (ocidRequest's setAutomaticallyDetectsLanguage:(true))
152    (ocidRequest's setRecognitionLanguages:{"en", "ja"})
153    (ocidRequest's setUsesLanguageCorrection:(false))
154    #results
155    (ocidHandler's performRequests:(refMe's NSArray's arrayWithObject:(ocidRequest)) |error| :(reference))
156    set ocidResponseArray to ocidRequest's results()
157    #戻り値を格納するテキスト
158    set ocidFirstOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
159    set ocidSecondOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
160    set ocidSaveString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
161    #戻り値の数だけ々
162    repeat with itemArray in ocidResponseArray
163      #候補数指定 1−10 ここでは2種の候補を戻す指定
164      set ocidRecognizedTextArray to (itemArray's topCandidates:(2))
165      set ocidFirstOpinion to ocidRecognizedTextArray's firstObject()
166      set ocidSecondOpinion to ocidRecognizedTextArray's lastObject()
167      (ocidFirstOpinionString's appendString:(ocidFirstOpinion's |string|()))
168      (ocidFirstOpinionString's appendString:("\n"))
169      (ocidSecondOpinionString's appendString:(ocidSecondOpinion's |string|()))
170      (ocidSecondOpinionString's appendString:("\n"))
171    end repeat
172    ##比較して相違点を探すならここで
173    (ocidSaveString's appendString:("-----第1候補\n\n"))
174    (ocidSaveString's appendString:(ocidFirstOpinionString))
175    (ocidSaveString's appendString:("\n\n-----第2候補\n\n"))
176    (ocidSaveString's appendString:(ocidSecondOpinionString))
177    ###保存
178    set listDone to (ocidSaveString's writeToURL:(ocidSaveTextFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference))
179    if (item 1 of listDone) is true then
180      log "正常終了"
181    else if (item 1 of listDone) is false then
182      log (item 2 of listDone)'s localizedDescription() as text
183      return display alert "  保存に失敗しました"
184    end if
185    #解放
186    set ocidSaveString to ""
187    set ocidReadImage to ""
188    set ocidNSInlineData to ""
189    
190  end repeat
191  
192end open
193
194################################
195# 日付 doGetDateNo()
196################################
197to doGetDateNo(strDateFormat)
198  ####日付情報の取得
199  set ocidDate to current application's NSDate's |date|()
200  ###日付のフォーマットを定義
201  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
202  ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
203  ocidNSDateFormatter's setDateFormat:strDateFormat
204  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
205  set strDateAndTime to ocidDateAndTime as text
206  return strDateAndTime
207end doGetDateNo
208
AppleScriptで生成しました

|

[Vision]画像ファイルのOCR


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

#!/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 framework "CoreImage"
use framework "VisionKit"
use framework "Vision"
use scripting additions

property refMe : a reference to current application
property refNSNotFound : a reference to 9.22337203685477E+18 + 5807

##設定 認識する最小文字サイズpt
set numMinPt to 8 as integer

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

###################################
#####ダイアログ
###################################a
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 ocidUserDesktopPath to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set aliasDefaultLocation to ocidUserDesktopPath as alias
set listChooseFileUTI to {"public.image"}
set strPromptText to "イメージファイルを選んでください" as text
set strMes to "イメージファイルを選んでください" as text
set listAliasFilePath to (choose file strMes with prompt strPromptText default location (aliasDefaultLocation) of type listChooseFileUTI with invisibles, showing package contents and multiple selections allowed) as list
###エリアス
set aliasFirstFilePath to item 1 of listAliasFilePath as alias
set strFirstFilePath to (POSIX path of aliasFirstFilePath) as text
set ocidFirstFilePath to refMe's NSString's stringWithString:(strFirstFilePath)
set ocidFirstFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFirstFilePath) isDirectory:false
set ocidContainerDirPathURL to ocidFirstFilePathURL's URLByDeletingLastPathComponent()
set aliasContainerDirPath to (ocidContainerDirPathURL's absoluteURL()) as alias
###################################
#####保存先ディレクトリ
###################################

set strMes to "保存先フォルダを選んでください" as text
set strPrompt to "保存先フォルダを選択してください" as text
try
  set aliasSaveDirPath to (choose folder strMes with prompt strPrompt default location aliasContainerDirPath with invisibles and showing package contents without multiple selections allowed) as alias
on error
log "エラーしました"
return "エラーしました"
end try
set strSaveDirPath to (POSIX path of aliasSaveDirPath) as text
set ocidSaveDirPathStr to refMe's NSString's stringWithString:(strSaveDirPath)
set ocidSaveDirPath to ocidSaveDirPathStr's stringByStandardizingPath()
set ocidSaveDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidSaveDirPath) isDirectory:true)

###################################
#####本処理
###################################
repeat with itemAliasFilePath in listAliasFilePath
  
  set strFilePath to (POSIX path of itemAliasFilePath) as text
  set ocidFilePath to (refMe's NSString's stringWithString:(strFilePath))
  set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
  set ocidFileName to ocidFilePathURL's lastPathComponent()
  set ocidPrefixName to ocidFileName's stringByDeletingPathExtension
  #####データ読み込み
  set ocidOption to (refMe's NSDataReadingMappedIfSafe)
  set listReadData to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error|:(reference))
  if (item 2 of listReadData) ≠ (missing value) then
log (item 2 of listReadStings)'s localizedDescription() as text
return "データの読み込みに失敗しました"
  else
    set ocidReadData to (item 1 of listReadData)
  end if
  #####ImageRep画像の高さを取得
  ##画像に対しての8Ptテキストの比率--> MinimumTextHeightにセットする
  set ocidImageRep to (refMe's NSBitmapImageRep's imageRepWithData:(ocidReadData))
  set numImageHeight to ocidImageRep's pixelsHigh()
  set intTextHeight to (numMinPt / numImageHeight) as number
  #####OCR
  #VNImageRequestHandler's
  set ocidHandler to (refMe's VNImageRequestHandler's alloc()'s initWithData:(ocidReadData) options:(missing value))
  #VNRecognizeTextRequest's
  set ocidRequest to refMe's VNRecognizeTextRequest's alloc()'s init()
  set ocidOption to (refMe's VNRequestTextRecognitionLevelAccurate)
(ocidRequest's setRecognitionLevel:(ocidOption))
(ocidRequest's setMinimumTextHeight:(intTextHeight))
(ocidRequest's setAutomaticallyDetectsLanguage:(true))
(ocidRequest's setRecognitionLanguages:{"en", "ja"})
(ocidRequest's setUsesLanguageCorrection:(false))
  #results
(ocidHandler's performRequests:(refMe's NSArray's arrayWithObject:(ocidRequest)) |error|:(reference))
  set ocidResponseArray to ocidRequest's results()
  #戻り値を格納するテキスト
  set ocidFirstOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
  set ocidSecondOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
  set ocidSaveString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
  
  #戻り値の数だけ々
  repeat with itemArray in ocidResponseArray
    #候補数指定 1−10 ここでは2種の候補を戻す指定
    set ocidRecognizedTextArray to (itemArray's topCandidates:(2))
    set ocidFirstOpinion to ocidRecognizedTextArray's firstObject()
    set ocidSecondOpinion to ocidRecognizedTextArray's lastObject()
(ocidFirstOpinionString's appendString:(ocidFirstOpinion's |string|()))
(ocidFirstOpinionString's appendString:("\n"))
(ocidSecondOpinionString's appendString:(ocidSecondOpinion's |string|()))
(ocidSecondOpinionString's appendString:("\n"))
  end repeat
  ##比較して相違点を探すならここで
(ocidSaveString's appendString:("-----第1候補\n\n"))
(ocidSaveString's appendString:(ocidFirstOpinionString))
(ocidSaveString's appendString:("\n\n-----第2候補\n\n"))
(ocidSaveString's appendString:(ocidSecondOpinionString))
  
  ###保存
  set ocidSaveBaseFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidPrefixName))
  set ocidSaveFilePathURL to (ocidSaveBaseFilePathURL's URLByAppendingPathExtension:("txt"))
  set listDone to (ocidSaveString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
  if (item 1 of listDone) is true then
log (ocidPrefixName as text) & " : 正常終了"
  else if (item 1 of listDone) is false then
log (item 2 of listDone)'s localizedDescription() as text
return (ocidPrefixName as text) & " : 保存に失敗しました"
  end if
  
end repeat

tell application "Finder"
  
open folder aliasSaveDirPath
end tell

return





|

その他のカテゴリー

Acrobat Acrobat Annotation Acrobat BookMark Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Open Acrobat Plugin Acrobat python Acrobat Reader Acrobat Sequ Acrobat Sign 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 Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Audio 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 Guide 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 NSFileManager enumeratorAtURL 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 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 Events Plist 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 savedSearch AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript XMP AppleScript YouTube AppleScript Zero Suppress Applications CityCode Design github 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