AppleScript Automator

[Automator]フォルダ名を日付に



ダウンロード - automatorfoldertodate.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
005use AppleScript version "2.8"
006use framework "Foundation"
007use framework "AppKit"
008use scripting additions
009
010property refMe : a reference to current application
011
012
013on run {listAliasDirPath}
014  
015  repeat with itemAliasDirPath in listAliasDirPath
016    set aliasDirPath to itemAliasDirPath as alias
017    set strDirPath to (POSIX path of aliasDirPath) as text
018    set ocidDirPathStr to (refMe's NSString's stringWithString:(strDirPath))
019    set ocidDirPath to ocidDirPathStr's stringByStandardizingPath()
020    set ocidDirPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidDirPath) isDirectory:true)
021    set ocidContainerDirPathURL to ocidDirPathURL's URLByDeletingLastPathComponent()
022    set strDateNo to doGetDateNo({"yyyyMMdd", 1}) as text
023    set ocidMoveDirPathURL to (ocidContainerDirPathURL's URLByAppendingPathComponent:(strDateNo) isDirectory:(true))
024    
025    set appFileManager to refMe's NSFileManager's defaultManager()
026    set ListDone to (appFileManager's moveItemAtURL:(ocidDirPathURL) toURL:(ocidMoveDirPathURL) |error| :(reference))
027  end repeat
028  
029end run
030
031
032
033
034
035
036to doGetDateNo({argDateFormat, argCalendarNO})
037  ##渡された値をテキストで確定させて
038  set strDateFormat to argDateFormat as text
039  set intCalendarNO to argCalendarNO as integer
040  ###日付情報の取得
041  set ocidDate to current application's NSDate's |date|()
042  ###日付のフォーマットを定義(日本語)
043  set ocidFormatterJP to current application's NSDateFormatter's alloc()'s init()
044  ###和暦 西暦 カレンダー分岐
045  if intCalendarNO = 1 then
046    set ocidCalendarID to (current application's NSCalendarIdentifierGregorian)
047  else if intCalendarNO = 2 then
048    set ocidCalendarID to (current application's NSCalendarIdentifierJapanese)
049  else
050    set ocidCalendarID to (current application's NSCalendarIdentifierISO8601)
051  end if
052  set ocidCalendarJP to current application's NSCalendar's alloc()'s initWithCalendarIdentifier:(ocidCalendarID)
053  set ocidTimezoneJP to current application's NSTimeZone's alloc()'s initWithName:("Asia/Tokyo")
054  set ocidLocaleJP to current application's NSLocale's alloc()'s initWithLocaleIdentifier:("ja_JP_POSIX")
055  ###設定
056  ocidFormatterJP's setTimeZone:(ocidTimezoneJP)
057  ocidFormatterJP's setLocale:(ocidLocaleJP)
058  ocidFormatterJP's setCalendar:(ocidCalendarJP)
059  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterNoStyle)
060  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterShortStyle)
061  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterMediumStyle)
062  # ocidFormatterJP's setDateStyle:(current application's NSDateFormatterLongStyle)
063  ocidFormatterJP's setDateStyle:(current application's NSDateFormatterFullStyle)
064  ###渡された値でフォーマット定義
065  ocidFormatterJP's setDateFormat:(strDateFormat)
066  ###フォーマット適応
067  set ocidDateAndTime to ocidFormatterJP's stringFromDate:(ocidDate)
068  ###テキストで戻す
069  set strDateAndTime to ocidDateAndTime as text
070  return strDateAndTime
071end doGetDateNo
AppleScriptで生成しました

|

【自分用】フォルダアクション スクリーンキャプチャーのリサイズ(デュアルモニタに対応)



ダウンロード - 20241029.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004# 20241029デュアルモニタに対応した
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use framework "Foundation"
008use framework "AppKit"
009use framework "CoreImage"
010use framework "VisionKit"
011use framework "Vision"
012use scripting additions
013property refMe : a reference to current application
014property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
015################
016##フォルダも作るか?
017property boolMakeDir : false
018
019
020
021on run {argListFilePath}
022  
023  #必要なフォルダがあれば作る
024  set appFileManager to refMe's NSFileManager's defaultManager()
025  #Picturesフォルダ
026  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask))
027  set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
028  #テンポラリフォルダ
029  set ocidTempDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/TemporaryItems") isDirectory:(true))
030  #実寸保存先
031  set ocidSaveDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/AutomatorExport") isDirectory:(true))
032  #スモールの保存先
033  set ocidSmallDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/SmallExport") isDirectory:(true))
034  #TIFFの保存先
035  set ocidPostDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/PostImage") isDirectory:(true))
036  
037  if boolMakeDir is true then
038    set ocidAttrDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
039    (ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions))
040    #
041    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidTempDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference))
042    #
043    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference))
044    #
045    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidSmallDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference))
046    #
047    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidPostDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference))
048  end if
049  
050  ############################
051  #本処理
052  #【1】リネーム
053  #【2】72ppiでAutomatorExportに
054  #【3】半分のサイズをSmallExportに
055  #【4】OCRテキストをAutomatorExport
056  ############################
057  #デュアルモニタに対応するためのカウンタ
058  set numCntNo to (count of argListFilePath) as integer
059  
060  repeat with itemNo from 1 to (numCntNo) by 1
061    
062    set argAliasFilePath to (item itemNo of argListFilePath) as alias
063    ##入力ファイル
064    set strFilePath to (POSIX path of argAliasFilePath) as text
065    
066    set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
067    set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
068    set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
069    set ocidFileName to ocidFilePath's lastPathComponent()
070    set ocidExtensionName to ocidFilePathURL's pathExtension()
071    ###########################
072    #【1】リネーム
073    ###########################
074    
075    set strDateNo to doGetDateNo("yyyyMMdd-hhmmss")
076    set strDateNo to (strDateNo & "-" & itemNo)
077    
078    set ocidMoveTmpBaseFilePathURL to (ocidTempDirPathURL's URLByAppendingPathComponent:(strDateNo) isDirectory:(false))
079    #拡張子
080    set ocidTmpFilePathURL to (ocidMoveTmpBaseFilePathURL's URLByAppendingPathExtension:(ocidExtensionName))
081    #移動
082    set listDone to (appFileManager's moveItemAtURL:(ocidFilePathURL) toURL:(ocidTmpFilePathURL) |error| :(reference))
083    if (item 1 of listDone) is true then
084      log "【1】移動しました"
085    else if (item 2 of listDone) ≠ (missing value) then
086      log ((item 2 of listDone)'s localizedDescription()) as text
087      return display alert "Automatorファイルの移動に失敗しました"
088    end if
089    
090    ###########################
091    #【2】72ppiでAutomatorExportに
092    ###########################
093    #####データ読み込み
094    set ocidOption to (refMe's NSDataReadingMappedIfSafe)
095    set listReadData to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidTmpFilePathURL) options:(ocidOption) |error| :(reference))
096    if (item 2 of listReadData) ≠ (missing value) then
097      log (item 2 of listReadStings)'s localizedDescription() as text
098      return "【4】データの読み込みに失敗しました"
099    else
100      set ocidReadData to (item 1 of listReadData)
101    end if
102    
103    ##NSIMAGEに読み込む
104    set ocidReadImage to (refMe's NSImage's alloc()'s initWithData:(ocidReadData))
105    #サイズPT
106    set recordSize to ocidReadImage's |size|()
107    set numWidthPtSize to (recordSize's width) as number
108    set numHeightPtSize to (recordSize's height) as number
109    ##BitMapRepに変換
110    set ocidReadImageRepArray to ocidReadImage's representations()
111    set ocidReadImageRep to ocidReadImageRepArray's firstObject()
112    ##ピクセルサイズ取得
113    set numPixelsWidth to ocidReadImageRep's pixelsWide()
114    set numPixelsHeight to ocidReadImageRep's pixelsHigh()
115    #解像度の比率
116    set numMag to (numPixelsWidth / numWidthPtSize) as integer
117    #解像度と同じなら
118    if numMag = 1 then
119      set strSaveFileName to (strDateNo & "_" & numPixelsWidth & "x" & numPixelsHeight) as text
120    else
121      set numWidthPtSize to (numWidthPtSize) as integer
122      set numHeightPtSize to (height of recordSize) as integer
123      set strSaveFileName to (strDateNo & "_" & numWidthPtSize & "x" & numHeightPtSize & "@" & numMag) as text
124    end if
125    #原寸として移動する
126    set ocidSaveBasePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(false))
127    set ocidSaveFilePathURL to (ocidSaveBasePathURL's URLByAppendingPathExtension:(ocidExtensionName))
128    set listDone to (appFileManager's moveItemAtURL:(ocidTmpFilePathURL) toURL:(ocidSaveFilePathURL) |error| :(reference))
129    if (item 1 of listDone) is true then
130      log "【2】移動しました"
131    else if (item 2 of listDone) ≠ (missing value) then
132      log ((item 2 of listDone)'s localizedDescription()) as text
133      return display alert "Automator【2】移動に失敗しました"
134    end if
135    ###########################
136    #【3】半分のサイズをSmallExportに
137    ###########################
138    #まず72ppiにする
139    set ocidPixelsSize to refMe's NSMakeSize(numPixelsWidth, numPixelsHeight)
140    (ocidReadImageRep's setSize:(ocidPixelsSize))
141    #半分サイズ(数値の丸めで1ピクセルの誤差を容認)
142    set numSmallWidth to (numPixelsWidth / 2) as integer
143    set numSmallHeight to (numPixelsHeight / 2) as integer
144    set ocidSmallSize to refMe's NSMakeSize(numSmallWidth, numSmallHeight)
145    set ocidSmallRect to refMe's NSMakeRect(0, 0, numSmallWidth, numSmallHeight)
146    #出力用イメージ NSBitmapImageRep
147    # samplesPerPixel
148    set intSPP to 4 as integer
149    # bitsPerSample
150    set intBPS to 8 as integer
151    # bytesPerRow
152    set intBPR to (numSmallWidth * intSPP) as integer
153    # bitsPerPixel
154    set intBPP to 32 as integer
155    # RGB系のカラースペース
156    set ocidColorSpaceName to refMe's NSCalibratedRGBColorSpace
157    # アルファあり
158    set ocidBitmapFormat to refMe's NSAlphaFirstBitmapFormat
159    ##出力ピクセルサイズのブランクイメージ
160    set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numSmallWidth) pixelsHigh:(numSmallHeight) bitsPerSample:(intBPS) samplesPerPixel:(intSPP) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(intBPR) bitsPerPixel:(intBPP))
161    ###########################
162    #ArtBord
163    ### 初期化 CodeBase
164    refMe's NSGraphicsContext's saveGraphicsState()
165    ###Context
166    set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
167    ###生成された画像でNSGraphicsContext初期化
168    (refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
169    ##色を個別に指定する場合 値は0が暗 1が明
170    set ocidSetColor to (refMe's NSColor's colorWithSRGBRed:(1.0) green:(1.0) blue:(1.0) alpha:(0.0))
171    ocidSetColor's |set|()
172    ###画像生成
173    refMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:(numSmallWidth), height:(numSmallHeight)}})
174    #画像作成終了
175    refMe's NSGraphicsContext's restoreGraphicsState()
176    
177    ###########################
178    #合成 リザイスでNSCompositeSourceOver
179    ### 初期化
180    refMe's NSGraphicsContext's saveGraphicsState()
181    ###Context
182    set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
183    ###NSGraphicsContext初期化
184    (refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
185    ####NSCompositeSourceOver
186    set ocidDrawInRect to {origin:{x:(0), y:(0)}, |size|:{width:(numSmallWidth), Hight:(numSmallHeight)}}
187    set ocidFromRect to (refMe's NSZeroRect)
188    # set ocidOption to (refMe's NSCompositeSourceOver)
189    set ocidOption to (refMe's NSCompositingOperationSourceOver)
190    ##  set ocidOption to (refMe's NSCompositeCopy)
191    (ocidReadImageRep's drawInRect:(ocidDrawInRect) fromRect:(ocidFromRect) operation:(ocidOption) fraction:1.0 respectFlipped:true hints:(missing value))
192    #画像作成終了
193    refMe's NSGraphicsContext's restoreGraphicsState()
194    
195    ###########################
196    #保存オプション
197    set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
198    (ocidProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
199    (ocidProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
200    ##保存
201    set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidProperty))
202    #スモールの保存先
203    set strSmallFileName to (strDateNo & "_" & numPixelsWidth & "x" & numSmallHeight) as text
204    set ocidSmallBasePathURL to (ocidSmallDirPathURL's URLByAppendingPathComponent:(strSmallFileName))
205    set ocidSmallFilePathURL to (ocidSmallBasePathURL's URLByAppendingPathExtension:(ocidExtensionName))
206    # set boolDone to (ocidNSInlineData's writeToURL:(ocidSmallFilePathURL) atomically:true)
207    set ocidOption to (refMe's NSDataWritingAtomic)
208    set listDone to (ocidNSInlineData's writeToURL:(ocidSmallFilePathURL) options:(ocidOption) |error| :(reference))
209    if (item 1 of listDone) is true then
210      log "【3】保存しました"
211    else if (item 2 of listDone) ≠ (missing value) then
212      log ((item 2 of listDone)'s localizedDescription()) as text
213      return display alert "Automator【3】保存に失敗しました"
214    end if
215    
216    ###########################
217    #【4】OCRテキストをAutomatorExport
218    ###########################
219    set numMinPt to 8 as integer
220    
221    #####ImageRep画像の高さを取得
222    ##画像に対しての8Ptテキストの比率--> MinimumTextHeightにセットする
223    set ocidImageRep to (refMe's NSBitmapImageRep's imageRepWithData:(ocidReadData))
224    set numImageHeight to ocidImageRep's pixelsHigh()
225    set intTextHeight to (numMinPt / numImageHeight) as number
226    #####OCR
227    #VNImageRequestHandler's
228    set ocidHandler to (refMe's VNImageRequestHandler's alloc()'s initWithData:(ocidReadData) options:(missing value))
229    #VNRecognizeTextRequest's
230    set ocidRequest to refMe's VNRecognizeTextRequest's alloc()'s init()
231    set ocidOption to (refMe's VNRequestTextRecognitionLevelAccurate)
232    (ocidRequest's setRecognitionLevel:(ocidOption))
233    (ocidRequest's setMinimumTextHeight:(intTextHeight))
234    (ocidRequest's setAutomaticallyDetectsLanguage:(true))
235    (ocidRequest's setRecognitionLanguages:{"en", "ja"})
236    (ocidRequest's setUsesLanguageCorrection:(false))
237    #results
238    (ocidHandler's performRequests:(refMe's NSArray's arrayWithObject:(ocidRequest)) |error| :(reference))
239    set ocidResponseArray to ocidRequest's results()
240    #戻り値を格納するテキスト
241    set ocidFirstOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
242    set ocidSecondOpinionString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
243    set ocidSaveString to (refMe's NSMutableString's alloc()'s initWithCapacity:(0))
244    #戻り値の数だけ々
245    repeat with itemArray in ocidResponseArray
246      #候補数指定 1−10 ここでは2種の候補を戻す指定
247      set ocidRecognizedTextArray to (itemArray's topCandidates:(2))
248      set ocidFirstOpinion to ocidRecognizedTextArray's firstObject()
249      set ocidSecondOpinion to ocidRecognizedTextArray's lastObject()
250      (ocidFirstOpinionString's appendString:(ocidFirstOpinion's |string|()))
251      (ocidFirstOpinionString's appendString:("\r"))
252      (ocidSecondOpinionString's appendString:(ocidSecondOpinion's |string|()))
253      (ocidSecondOpinionString's appendString:("\r"))
254    end repeat
255    ##比較して相違点を探すならここで
256    (ocidSaveString's appendString:("-----第1候補\r\r"))
257    (ocidSaveString's appendString:(ocidFirstOpinionString))
258    (ocidSaveString's appendString:("\r\r-----第2候補\r\r"))
259    (ocidSaveString's appendString:(ocidSecondOpinionString))
260    ###保存
261    set ocidOcrBaseFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(false))
262    #拡張子
263    set ocidOcrFilePathURL to (ocidOcrBaseFilePathURL's URLByAppendingPathExtension:("txt"))
264    #保存
265    set listDone to (ocidSaveString's writeToURL:(ocidOcrFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference))
266    if (item 1 of listDone) is true then
267      log "【4】正常終了"
268    else if (item 1 of listDone) is false then
269      log (item 2 of listDone)'s localizedDescription() as text
270      return display alert " 【4】 保存に失敗しました"
271    end if
272    
273    set ocidSaveString to ""
274    set ocidReadData to ""
275    set ocidNSInlineData to ""
276    set ocidReadImageRepArray to ""
277    set ocidReadImageRep to ""
278    
279  end repeat
280end run
281
282
283################################
284# 日付 doGetDateNo()
285################################
286to doGetDateNo(strDateFormat)
287  ####日付情報の取得
288  set ocidDate to current application's NSDate's |date|()
289  ###日付のフォーマットを定義
290  set ocidNSDateFormatter to current application's NSDateFormatter's alloc()'s init()
291  ocidNSDateFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"ja_JP_POSIX")
292  ocidNSDateFormatter's setDateFormat:strDateFormat
293  set ocidDateAndTime to ocidNSDateFormatter's stringFromDate:ocidDate
294  set strDateAndTime to ocidDateAndTime as text
295  return strDateAndTime
296end doGetDateNo
AppleScriptで生成しました

|

[Automator workflow]メタデータ削除



ダウンロード - メタデータ削除.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002use AppleScript version "2.6"
003use framework "Foundation"
004use framework "AppKit"
005use scripting additions
006property refMe : a reference to current application
007
008on run {input}
009  
010  set strExifToolFilePath to ("~/Library/Services/メタデータ削除.workflow/Contents/exiftool/exiftool") as text
011  set ocidExifToolFilePathStr to refMe's NSString's stringWithString:(strExifToolFilePath)
012  set ocidExifToolFilePath to ocidExifToolFilePathStr's stringByStandardizingPath()
013  set ocidExifToolFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidExifToolFilePath) isDirectory:(false)
014  set strExifToolFilePath to (ocidExifToolFilePathURL's |path|) as text
015  repeat with itemAliasFilePath in input
016    set aliasFilePath to itemAliasFilePath as alias
017    set strFilePath to (POSIX path of aliasFilePath) as text
018    set strCommandText to ("/bin/zsh -c '\"" & strExifToolFilePath & "\"  -overwrite_original -all= \"" & strFilePath & "\"'") as text
019    log strCommandText
020    try
021      do shell script strCommandText
022    on error
023      set strMes to (strFilePath & "失敗しました") as text
024      display alert strMes
025    end try
026    
027  end repeat
028  
029end run
AppleScriptで生成しました

|

[Automator]exif2html exifデータをHTML表示させるクイックアクション

設定が必要です
20240826102534_1160x12062

ダウンロード - exif2html.zip




AppleScript サンプルコード

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

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#com.cocolog-nifty.quicktimer.icefloe
004----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
005use AppleScript version "2.8"
006use framework "Foundation"
007use framework "UniformTypeIdentifiers"
008use framework "AppKit"
009use scripting additions
010
011property refMe : a reference to current application
012
013
014on run {listAliasFilePath}
015  
016  #一般的にはパスはこちら
017  # set strExifPath to "/usr/local/bin/exiftool/exiftool" as text
018  #自分用
019  set strExifPath to "~/bin/exiftool/exiftool" as text
020  #exiftoolパス処理
021  set ocidExifPathStr to refMe's NSString's stringWithString:(strExifPath)
022  set ocidExifPath to ocidExifPathStr's stringByStandardizingPath()
023  set ocidExifPathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidExifPath) isDirectory:false)
024  set strExifPath to ocidExifPathURL's |path| as text
025  #
026  set appFileManager to refMe's NSFileManager's defaultManager()
027  ####出力先/var/folders/XX/(再起動時に削除されます)
028  set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory
029  set ocidVarFoldersDirURL to ocidTemporaryDirPathURL's URLByDeletingLastPathComponent()
030  set ocidTemporaryItemsPathURL to ocidVarFoldersDirURL's URLByAppendingPathComponent:"TemporaryItems"
031  #set aliasTemporaryItems to (ocidTemporaryItemsPathURL's absoluteURL()) as alias
032  set strTempDirPath to ocidTemporaryItemsPathURL's absoluteString() as text
033  
034  ##フォルダがなければ作る
035  set boolDirExists to appFileManager's fileExistsAtPath:(ocidTemporaryItemsPathURL's |path|()) isDirectory:(true)
036  if boolDirExists = true then
037    log "起動時に削除されるフォルダはすでにあります"
038  else if boolDirExists = false then
039    log "起動時に削除されるフォルダを作ります"
040    set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
041    ocidAttrDict's setValue:(511) forKey:(refMe's NSFilePosixPermissions)
042    set listDone to appFileManager's createDirectoryAtURL:(ocidTemporaryItemsPathURL) withIntermediateDirectories:(true) attributes:(ocidAttrDict) |error| :(reference)
043  end if
044  
045  repeat with itemAliasFilePath in listAliasFilePath
046    ##パス
047    set strFilePath to (POSIX path of itemAliasFilePath) as text
048    set ocidFilePathStr to (refMe's NSString's stringWithString:(strFilePath))
049    set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
050    set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
051    set ocidFileName to ocidFilePathURL's lastPathComponent()
052    #保存先
053    set ocidBaseFilePathURL to (ocidTemporaryItemsPathURL's URLByAppendingPathComponent:(ocidFileName))
054    set ocidSaveFilePathURL to (ocidBaseFilePathURL's URLByAppendingPathExtension:("html"))
055    #コマンド整形
056    set strCommandText to ("\"" & strExifPath & "\"  -lang ja   \"" & strFilePath & "\"") as text
057    #コマンド実行
058    try
059      set strResponseExif to (do shell script strCommandText) as text
060    on error
061      set strResponseExif to ("エラーが発生しました : Unknown file type")
062    end try
063    #戻り値
064    set ocidExifStrings to (refMe's NSString's stringWithString:(strResponseExif))
065    ##インテント除去
066    set ocidReplacedStrings to (ocidExifStrings's stringByReplacingOccurrencesOfString:("    ") withString:(""))
067    #改行をUNIXに強制
068    set ocidExifStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("\n\r") withString:("\n"))
069    set ocidExifStrings to (ocidExifStrings's stringByReplacingOccurrencesOfString:("\r") withString:("\n"))
070    set ocidExifStrings to (ocidExifStrings's stringByReplacingOccurrencesOfString:("\n\n") withString:("\n"))
071    #改行でリストに
072    set ocidChrSet to (refMe's NSCharacterSet's characterSetWithCharactersInString:("\n"))
073    set ocidMainArray to (ocidExifStrings's componentsSeparatedByCharactersInSet:(ocidChrSet))
074    #出力用のDICT
075    set ocidExifDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
076    #リストの数だけ繰り返し
077    repeat with itemArray in ocidMainArray
078      set ocidSubArray to (itemArray's componentsSeparatedByString:(": "))
079      set ocidSetKey to (ocidSubArray's objectAtIndex:(0))
080      set ocidSetValue to (ocidSubArray's objectAtIndex:(1))
081      (ocidExifDict's setValue:(ocidSetValue) forKey:(ocidSetKey))
082    end repeat
083    #DICTからキーを取得して
084    set ocidAllKey to ocidExifDict's allKeys()
085    #ソートしておく
086    set ocidSortedKeyArray to (ocidAllKey's sortedArrayUsingSelector:("localizedStandardCompare:"))
087    
088    ##############################
089    # XML 生成開始
090    ##############################
091    # タイトル
092    set strTitleText to ("【ExifTool】: " & (ocidFileName as text) & " :メタデータ一覧") as text
093    ########################################
094    #headerに渡すエレメント
095    set ocidSetHeaderElement to (refMe's NSXMLElement's elementWithName:("div"))
096    set ocidH3Element to (refMe's NSXMLElement's elementWithName:("h3"))
097    (ocidH3Element's setStringValue:(strTitleText))
098    (ocidSetHeaderElement's addChild:(ocidH3Element))
099    
100    ########################################
101    #footerに渡すエレメント
102    set ocidSetFooterElement to (refMe's NSXMLElement's elementWithName:("div"))
103    set ocidAElement to (refMe's NSXMLElement's elementWithName:("a"))
104    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("href") stringValue:("https://quicktimer.cocolog-nifty.com/"))
105    (ocidAElement's addAttribute:(ocidAddNode))
106    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("target") stringValue:("_blank"))
107    (ocidAElement's addAttribute:(ocidAddNode))
108    set strContents to ("AppleScriptで生成しました") as text
109    (ocidAElement's setStringValue:(strContents))
110    (ocidSetFooterElement's addChild:(ocidAElement))
111    
112    ########################################
113    #articleに渡すエレメント
114    set ocidSetArticleElement to (refMe's NSXMLElement's elementWithName:("div"))
115    set ocidH3Element to (refMe's NSXMLElement's elementWithName:("h5"))
116    (ocidH3Element's setStringValue:(strCommandText))
117    (ocidSetArticleElement's addChild:(ocidH3Element))
118    ########################################
119    #テーブル部生成開始
120    set ocidTableElement to (refMe's NSXMLElement's elementWithName:("table"))
121    #########【caption】
122    set ocidCaptionElement to (refMe's NSXMLElement's elementWithName:("caption"))
123    set strCaptionText to ((ocidFileName as text) & " : メタデータ一覧") as text
124    (ocidCaptionElement's setStringValue:(strCaptionText))
125    (ocidTableElement's addChild:(ocidCaptionElement))
126    #########【colgroup】
127    set ocidColgroupElement to (refMe's NSXMLElement's elementWithName:("colgroup"))
128    #########【col】col生成
129    #項目番号
130    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("col"))
131    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("LineNo"))
132    (ocidAddElement's addAttribute:(ocidAddNode))
133    (ocidColgroupElement's addChild:(ocidAddElement))
134    #キー
135    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("col"))
136    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("キー名"))
137    (ocidAddElement's addAttribute:(ocidAddNode))
138    (ocidColgroupElement's addChild:(ocidAddElement))
139    #値
140    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("col"))
141    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("値"))
142    (ocidAddElement's addAttribute:(ocidAddNode))
143    (ocidColgroupElement's addChild:(ocidAddElement))
144    #テーブルエレメントに追加
145    (ocidTableElement's addChild:(ocidColgroupElement))
146    #########【thead】
147    set ocidTheadElement to (refMe's NSXMLElement's elementWithName:("thead"))
148    set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
149    #項目番号
150    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
151    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("lineNo"))
152    (ocidAddElement's addAttribute:(ocidAddNode))
153    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:("lineNo"))
154    (ocidAddElement's addAttribute:(ocidAddNode))
155    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
156    (ocidAddElement's addAttribute:(ocidAddNode))
157    (ocidAddElement's setStringValue:("\"))
158    (ocidTrElement's addChild:(ocidAddElement))
159    #キー
160    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
161    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("key"))
162    (ocidAddElement's addAttribute:(ocidAddNode))
163    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:("key"))
164    (ocidAddElement's addAttribute:(ocidAddNode))
165    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
166    (ocidAddElement's addAttribute:(ocidAddNode))
167    (ocidAddElement's setStringValue:("キー名"))
168    (ocidTrElement's addChild:(ocidAddElement))
169    #値
170    set ocidAddElement to (refMe's NSXMLElement's elementWithName:("th"))
171    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("value"))
172    (ocidAddElement's addAttribute:(ocidAddNode))
173    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("id") stringValue:("value"))
174    (ocidAddElement's addAttribute:(ocidAddNode))
175    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
176    (ocidAddElement's addAttribute:(ocidAddNode))
177    (ocidAddElement's setStringValue:("値"))
178    (ocidTrElement's addChild:(ocidAddElement))
179    #TRをTHEADにセット
180    (ocidTheadElement's addChild:(ocidTrElement))
181    #THEADをテーブルにセット
182    (ocidTableElement's addChild:(ocidTheadElement))
183    ########################################
184    set numLineNo to 1 as integer
185    #【tbody】
186    set ocidTbodyElement to (refMe's NSXMLElement's elementWithName:("tbody"))
187    repeat with itemArray in ocidSortedKeyArray
188      set ocidExifValue to (ocidExifDict's valueForKey:(itemArray))
189      #TRの開始
190      set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
191      ####項番処理
192      set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
193      set strSetValue to ("項目番号:" & numLineNo) as text
194      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(strSetValue))
195      (ocidThElement's addAttribute:(ocidAddNode))
196      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:("LineNo"))
197      (ocidThElement's addAttribute:(ocidAddNode))
198      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
199      (ocidThElement's addAttribute:(ocidAddNode))
200      (ocidThElement's setStringValue:(numLineNo as text))
201      (ocidTrElement's addChild:(ocidThElement))
202      ####キー
203      set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
204      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(itemArray as text))
205      (ocidThElement's addAttribute:(ocidAddNode))
206      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:("key"))
207      (ocidThElement's addAttribute:(ocidAddNode))
208      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("col"))
209      (ocidThElement's addAttribute:(ocidAddNode))
210      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("class") stringValue:("tbody_th_title"))
211      (ocidThElement's addAttribute:(ocidAddNode))
212      (ocidThElement's setStringValue:(itemArray as text))
213      (ocidTrElement's addChild:(ocidThElement))
214      ####値
215      set ocidTdElement to (refMe's NSXMLElement's elementWithName:("td"))
216      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:(ocidExifValue as text))
217      (ocidTdElement's addAttribute:(ocidAddNode))
218      set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("headers") stringValue:("value"))
219      (ocidTdElement's addAttribute:(ocidAddNode))
220      (ocidTdElement's setStringValue:(ocidExifValue as text))
221      (ocidTrElement's addChild:(ocidTdElement))
222      #
223      (ocidTbodyElement's addChild:(ocidTrElement))
224      set numLineNo to numLineNo + 1 as integer
225    end repeat
226    #TBODYをテーブルにセット
227    (ocidTableElement's addChild:(ocidTbodyElement))
228    #【tfoot】 TRで
229    set ocidTfootElement to (refMe's NSXMLElement's elementWithName:("tfoot"))
230    set ocidTrElement to (refMe's NSXMLElement's elementWithName:("tr"))
231    #colspan指定して1行でセット
232    set ocidThElement to (refMe's NSXMLElement's elementWithName:("th"))
233    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("title") stringValue:("テーブルの終わり"))
234    (ocidThElement's addAttribute:(ocidAddNode))
235    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("colspan") stringValue:(3))
236    (ocidThElement's addAttribute:(ocidAddNode))
237    set ocidAddNode to (refMe's NSXMLNode's attributeWithName:("scope") stringValue:("row"))
238    (ocidThElement's addAttribute:(ocidAddNode))
239    #
240    set strContents to ("項目数 : " & (numLineNo as text)) as text
241    (ocidThElement's setStringValue:(strContents))
242    #THをTRにセットして
243    (ocidTrElement's addChild:(ocidThElement))
244    #TRをTFOOTにセット
245    (ocidTfootElement's addChild:(ocidTrElement))
246    #TFOOTをテーブルにセット
247    (ocidTableElement's addChild:(ocidTfootElement))
248    #テーブルをアーティクルにセット
249    (ocidSetArticleElement's addChild:(ocidTableElement))
250    ##############################
251    #HTMLにする
252    ##############################
253    set ocidHTML to doMakeRootElement({ocidSetHeaderElement, ocidSetArticleElement, ocidSetFooterElement, strTitleText})
254    ##############################
255    #保存
256    ##############################
257    #読み取りやすい表示
258    set ocidXMLdata to (ocidHTML's XMLDataWithOptions:(refMe's NSXMLNodePrettyPrint))
259    #保存
260    set listDone to (ocidXMLdata's writeToURL:(ocidSaveFilePathURL) options:(refMe's NSDataWritingAtomic) |error| :(reference))
261    set aliasFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias
262    ####【6】ブラウザで開く
263    tell application "Finder"
264      open location aliasFilePath
265    end tell
266    (*
267    ####【6】 テキストエディットで開く
268    tell application "TextEdit"
269      activate
270      open file aliasFilePath
271    end tell
272        *)
273    
274  end repeat
275  log "処理終了"
276end run
277
278
279
280
281
282
283
284
285############################################################
286# 基本的なHTMLの構造
287(*
288doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents,argTitleText})
289HTMLのBODY部
290header
291article
292footerにそれぞれAddchildするデータをリストで渡す
293戻り値はRootエレメントにセットされた
294NSXMLDocumentを戻すので 保存すればOK
295*)
296############################################################
297to doMakeRootElement({argHeaderContents, argArticleContents, argFooterContents, argTitleText})
298  #XML初期化
299  set ocidXMLDoc to refMe's NSXMLDocument's alloc()'s init()
300  ocidXMLDoc's setDocumentContentKind:(refMe's NSXMLDocumentHTMLKind)
301  # DTD付与
302  set ocidDTD to refMe's NSXMLDTD's alloc()'s init()
303  ocidDTD's setName:("html")
304  ocidXMLDoc's setDTD:(ocidDTD)
305  #
306  set ocidRootElement to refMe's NSXMLElement's elementWithName:("html")
307  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("lang") stringValue:("ja")
308  ocidRootElement's addAttribute:(ocidAddNode)
309  #
310  set ocidHeadElement to refMe's NSXMLElement's elementWithName:("head")
311  #
312  set ocidAddElement to refMe's NSXMLElement's elementWithName:("title")
313  ocidAddElement's setStringValue:(argTitleText)
314  ocidHeadElement's addChild:(ocidAddElement)
315  # http-equiv
316  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
317  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Type")
318  ocidAddElement's addAttribute:(ocidAddNode)
319  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/html; charset=UTF-8")
320  ocidAddElement's addAttribute:(ocidAddNode)
321  ocidHeadElement's addChild:(ocidAddElement)
322  #
323  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
324  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Style-Type")
325  ocidAddElement's addAttribute:(ocidAddNode)
326  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/css")
327  ocidAddElement's addAttribute:(ocidAddNode)
328  ocidHeadElement's addChild:(ocidAddElement)
329  #
330  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
331  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("http-equiv") stringValue:("Content-Script-Type")
332  ocidAddElement's addAttribute:(ocidAddNode)
333  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("text/javascript")
334  ocidAddElement's addAttribute:(ocidAddNode)
335  ocidHeadElement's addChild:(ocidAddElement)
336  #
337  set ocidAddElement to refMe's NSXMLElement's elementWithName:("meta")
338  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("name") stringValue:("viewport")
339  ocidAddElement's addAttribute:(ocidAddNode)
340  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("content") stringValue:("width=720")
341  ocidAddElement's addAttribute:(ocidAddNode)
342  ocidHeadElement's addChild:(ocidAddElement)
343  #
344  set ocidAddElement to refMe's NSXMLElement's elementWithName:("style")
345  ocidAddElement's setStringValue:("body { margin: 10px; background-color: #FFFFFF; } 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: 360px;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; } .tbody_th_title{text-align: left;} 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 } }")
346  ocidHeadElement's addChild:(ocidAddElement)
347  ocidRootElement's addChild:(ocidHeadElement)
348  #
349  #ボディエレメント
350  set ocidBodyElement to refMe's NSXMLElement's elementWithName:("body")
351  #ヘッダー
352  set ocidHeaderElement to refMe's NSXMLElement's elementWithName:("header")
353  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("header")
354  ocidHeaderElement's addAttribute:(ocidAddNode)
355  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_header")
356  ocidHeaderElement's addAttribute:(ocidAddNode)
357  ocidHeaderElement's addChild:(argHeaderContents)
358  ocidBodyElement's addChild:(ocidHeaderElement)
359  #アーティクル
360  set ocidArticleElement to refMe's NSXMLElement's elementWithName:("article")
361  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("article")
362  ocidArticleElement's addAttribute:(ocidAddNode)
363  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_article")
364  ocidArticleElement's addAttribute:(ocidAddNode)
365  ocidArticleElement's addChild:(argArticleContents)
366  ocidBodyElement's addChild:(ocidArticleElement)
367  #フッター
368  set ocidFooterElement to refMe's NSXMLElement's elementWithName:("footer")
369  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("id") stringValue:("footer")
370  ocidFooterElement's addAttribute:(ocidAddNode)
371  set ocidAddNode to refMe's NSXMLNode's attributeWithName:("class") stringValue:("body_footer")
372  ocidFooterElement's addAttribute:(ocidAddNode)
373  ocidFooterElement's addChild:(argFooterContents)
374  ocidBodyElement's addChild:(ocidFooterElement)
375  #ボディをROOTエレメントにセット
376  ocidRootElement's addChild:(ocidBodyElement)
377  #ROOTをXMLにセット
378  ocidXMLDoc's setRootElement:(ocidRootElement)
379  #値を戻す
380  return ocidXMLDoc
381end doMakeRootElement
382
AppleScriptで生成しました

|

[Automater]スクリーンキャプチャーと同時に処理を行う(OCRをテキストで保存)


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#com.cocolog-nifty.quicktimer.icefloe
#Automater用です
#保存先フォルダ等に指定があります(このままでは動作しないよ的な)
----+----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
################
##フォルダも作るか?
property boolMakeDir : true



#on run {argListFilePath}
on run
  #必要なフォルダがあれば作る
  set appFileManager to refMe's NSFileManager's defaultManager()
  #Picturesフォルダ
  set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSPicturesDirectory) inDomains:(refMe's NSUserDomainMask))
  set ocidPicturesDirPathURL to ocidURLsArray's firstObject()
  #テンポラリフォルダ
  set ocidTempDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/TemporaryItems") isDirectory:(true))
  #実寸保存先
  set ocidSaveDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/AutomatorExport") isDirectory:(true))
  #スモールの保存先
  set ocidSmallDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/SmallExport") isDirectory:(true))
  #TIFFの保存先
  set ocidPostDirPathURL to (ocidPicturesDirPathURL's URLByAppendingPathComponent:("ScreenCapture/PostImage") isDirectory:(true))
  
  if boolMakeDir is true then
    set ocidAttrDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
(ocidAttrDict's setValue:(493) forKey:(refMe's NSFilePosixPermissions))
    #
    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidTempDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference))
    #
    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference))
    #
    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidSmallDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference))
    #
    set listBoolMakeDir to (appFileManager's createDirectoryAtURL:(ocidPostDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference))
  end if
  
  ############################
  #本処理
  #【1】リネーム
  #【2】72ppiでAutomatorExportに
  #【3】半分のサイズをSmallExportに
  #【4】OCRテキストをAutomatorExport
  ############################
  # repeat with argAliasFilePath in argListFilePath
  ##入力ファイル
  # set strFilePath to (POSIX path of argAliasFilePath) as text
  set strFilePath to ("~/Pictures/ScreenCapture/ScreenCapture/screen.png") 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 ocidFileName to ocidFilePath's lastPathComponent()
  set ocidExtensionName to ocidFilePathURL's pathExtension()
  ###########################
  #【1】リネーム
  ###########################
  #日付時間ファイル名
  set strDateNo to doGetDateNo("yyyyMMdd-hhmmss")
  set ocidMoveTmpBaseFilePathURL to (ocidTempDirPathURL's URLByAppendingPathComponent:(strDateNo) isDirectory:(false))
  #拡張子
  set ocidTmpFilePathURL to (ocidMoveTmpBaseFilePathURL's URLByAppendingPathExtension:(ocidExtensionName))
  #移動
  set listDone to (appFileManager's moveItemAtURL:(ocidFilePathURL) toURL:(ocidTmpFilePathURL) |error|:(reference))
  if (item 1 of listDone) is true then
log "【1】移動しました"
  else if (item 2 of listDone) ≠ (missing value) then
log ((item 2 of listDone)'s localizedDescription()) as text
return display alert "Automatorファイルの移動に失敗しました"
  end if
  ###########################
  #【2】72ppiでAutomatorExportに
  ###########################
  #####データ読み込み
  set ocidOption to (refMe's NSDataReadingMappedIfSafe)
  set listReadData to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidTmpFilePathURL) options:(ocidOption) |error|:(reference))
  if (item 2 of listReadData) ≠ (missing value) then
log (item 2 of listReadStings)'s localizedDescription() as text
return "【4】データの読み込みに失敗しました"
  else
    set ocidReadData to (item 1 of listReadData)
  end if
  
  ##NSIMAGEに読み込む
  set ocidReadImage to (refMe's NSImage's alloc()'s initWithData:(ocidReadData))
  #サイズPT
  set recordSize to ocidReadImage's |size|()
  set numWidthPtSize to (recordSize's width) as number
  set numHeightPtSize to (recordSize's height) as number
  ##BitMapRepに変換
  set ocidReadImageRepArray to ocidReadImage's representations()
  set ocidReadImageRep to ocidReadImageRepArray's firstObject()
  ##ピクセルサイズ取得
  set numPixelsWidth to ocidReadImageRep's pixelsWide()
  set numPixelsHeight to ocidReadImageRep's pixelsHigh()
  #解像度の比率
  set numMag to (numPixelsWidth / numWidthPtSize) as integer
  #解像度と同じなら
  if numMag = 1 then
    set strSaveFileName to (strDateNo & "-" & numPixelsWidth & "x" & numPixelsHeight) as text
  else
    set numWidthPtSize to (numWidthPtSize) as integer
    set numHeightPtSize to (height of recordSize) as integer
    set strSaveFileName to (strDateNo & "-" & numWidthPtSize & "x" & numHeightPtSize & "@" & numMag) as text
  end if
  #原寸として移動する
  set ocidSaveBasePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(false))
  set ocidSaveFilePathURL to (ocidSaveBasePathURL's URLByAppendingPathExtension:(ocidExtensionName))
  set listDone to (appFileManager's moveItemAtURL:(ocidTmpFilePathURL) toURL:(ocidSaveFilePathURL) |error|:(reference))
  if (item 1 of listDone) is true then
log "【2】移動しました"
  else if (item 2 of listDone) ≠ (missing value) then
log ((item 2 of listDone)'s localizedDescription()) as text
return display alert "Automator【2】移動に失敗しました"
  end if
  ###########################
  #【3】半分のサイズをSmallExportに
  ###########################
  #まず72ppiにする
  set ocidPixelsSize to refMe's NSMakeSize(numPixelsWidth, numPixelsHeight)
(ocidReadImageRep's setSize:(ocidPixelsSize))
  #半分サイズ(数値の丸めで1ピクセルの誤差を容認)
  set numSmallWidth to (numPixelsWidth / 2) as integer
  set numSmallHeight to (numPixelsHeight / 2) as integer
  set ocidSmallSize to refMe's NSMakeSize(numSmallWidth, numSmallHeight)
  set ocidSmallRect to refMe's NSMakeRect(0, 0, numSmallWidth, numSmallHeight)
  #出力用イメージ NSBitmapImageRep
  # samplesPerPixel
  set intSPP to 4 as integer
  # bitsPerSample
  set intBPS to 8 as integer
  # bytesPerRow
  set intBPR to (numSmallWidth * intSPP) as integer
  # bitsPerPixel
  set intBPP to 32 as integer
  # RGB系のカラースペース
  set ocidColorSpaceName to refMe's NSCalibratedRGBColorSpace
  # アルファあり
  set ocidBitmapFormat to refMe's NSAlphaFirstBitmapFormat
  ##出力ピクセルサイズのブランクイメージ
  set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(numSmallWidth) pixelsHigh:(numSmallHeight) bitsPerSample:(intBPS) samplesPerPixel:(intSPP) hasAlpha:(true) isPlanar:(false) colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:(intBPR) bitsPerPixel:(intBPP))
  ###########################
  #ArtBord
  ### 初期化 CodeBase
refMe's NSGraphicsContext's saveGraphicsState()
  ###Context
  set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
  ###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
  ##色を個別に指定する場合 値は0が暗 1が明
  set ocidSetColor to (refMe's NSColor's colorWithSRGBRed:(1.0) green:(1.0) blue:(1.0) alpha:(0.0))
ocidSetColor's |set|()
  ###画像生成
refMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:(numSmallWidth), height:(numSmallHeight)}})
  #画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()
  
  ###########################
  #合成 リザイスでNSCompositeSourceOver
  ### 初期化
refMe's NSGraphicsContext's saveGraphicsState()
  ###Context
  set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
  ###NSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
  ####NSCompositeSourceOver
  set ocidDrawInRect to {origin:{x:(0), y:(0)}, |size|:{width:(numSmallWidth), Hight:(numSmallHeight)}}
  set ocidFromRect to (refMe's NSZeroRect)
  # set ocidOption to (refMe's NSCompositeSourceOver)
  set ocidOption to (refMe's NSCompositingOperationSourceOver)
  ## set ocidOption to (refMe's NSCompositeCopy)
(ocidReadImageRep's drawInRect:(ocidDrawInRect) fromRect:(ocidFromRect) operation:(ocidOption) fraction:1.0 respectFlipped:true hints:(missing value))
  #画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()
  
  ###########################
  #保存オプション
  set ocidProperty to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
(ocidProperty's setObject:(refMe's NSNumber's numberWithBool:false) forKey:(refMe's NSImageInterlaced))
(ocidProperty's setObject:(refMe's NSNumber's numberWithDouble:(1 / 2.2)) forKey:(refMe's NSImageGamma))
  ##保存
  set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:(ocidProperty))
  #スモールの保存先
  set strSmallFileName to (strDateNo & "-" & numPixelsWidth & "x" & numSmallHeight) as text
  set ocidSmallBasePathURL to (ocidSmallDirPathURL's URLByAppendingPathComponent:(strSmallFileName))
  set ocidSmallFilePathURL to (ocidSmallBasePathURL's URLByAppendingPathExtension:(ocidExtensionName))
  # set boolDone to (ocidNSInlineData's writeToURL:(ocidSmallFilePathURL) atomically:true)
  set ocidOption to (refMe's NSDataWritingAtomic)
  set listDone to (ocidNSInlineData's writeToURL:(ocidSmallFilePathURL) options:(ocidOption) |error|:(reference))
  if (item 1 of listDone) is true then
log "【3】保存しました"
  else if (item 2 of listDone) ≠ (missing value) then
log ((item 2 of listDone)'s localizedDescription()) as text
return display alert "Automator【3】保存に失敗しました"
  end if
  
  ###########################
  #【4】OCRテキストをAutomatorExport
  ###########################
  set numMinPt to 8 as integer
  
  #####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 ocidOcrBaseFilePathURL to (ocidSaveDirPathURL's URLByAppendingPathComponent:(strSaveFileName) isDirectory:(false))
  #拡張子
  set ocidOcrFilePathURL to (ocidOcrBaseFilePathURL's URLByAppendingPathExtension:("txt"))
  #保存
  set listDone to (ocidSaveString's writeToURL:(ocidOcrFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
  if (item 1 of listDone) is true then
log "【4】正常終了"
  else if (item 1 of listDone) is false then
log (item 2 of listDone)'s localizedDescription() as text
return display alert " 【4】 保存に失敗しました"
  end if
  
  set ocidSaveString to ""
  set ocidReadData to ""
  set ocidNSInlineData to ""
  set ocidReadImageRepArray to ""
  set ocidReadImageRep to ""
  
  # end repeat
end run


################################
# 日付 doGetDateNo()
################################
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

|

[Automator]script2Applescript スクリプトをテキスト形式にする(修正 パスのエスケープ処理を追加)

ダウンロード - scpt2applescript.zip


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

on run {argFileInput}
  set numCntSelectedObject to (count of argFileInput) as integer
  if numCntSelectedObject = 0 then
return "未選択です"
  end if
  repeat with itemFilePath in argFileInput
    set aliasFilePath to itemFilePath as alias
    set objInfo to get info for aliasFilePath
    if (folder of objInfo) is true then
log "フォルダなので処理しない"
    else if (type identifier of objInfo) is "com.apple.applescript.text" then
log "すでにテキスト形式なので処理しない"
    else if (type identifier of objInfo) is "com.apple.applescript.script" then
      set strExtension to name extension of objInfo
      set strNewExtension to "applescript"
      set strName to (name of objInfo) as text
      tell application "Finder"
        set aliasSaveDirPath to (container of aliasFilePath) as alias
        set strSaveDirPath to POSIX path of aliasSaveDirPath as text
      end tell
      set strFilePath to POSIX path of aliasFilePath as text
      set strSaveFilePath to doReplace(strFilePath, ".scpt", ".applescript") as text
      set aliasSavePath to POSIX file strSaveFilePath as «class furl»
      #別名保存
      tell application "Script Editor"
open aliasFilePath
save the front document as "text" in aliasSavePath
close front document
      end tell
      ##エスケープ エラーよけ
      set strSaveFilePath to doReplace(strSaveFilePath, "\"", "\\\"")
      set strSaveFilePath to doReplace(strSaveFilePath, "'", "\\'")
      set theComandText to ("chmod 755 \"" & strSaveFilePath & "\"") as text
do shell script theComandText
      #スクリプトはゴミ箱へ
      tell application "Finder"
move aliasFilePath to trash
      end tell
    else
log "スクリプト形式以外は処理しない"
    end if
  end repeat
end run


##文字列置換
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

|

[Automator]WeblocファイルからURLをコピーする

ダウンロード - webloc2clipboard.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 "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application
property strBundleID : "com.apple.Safari" as text


on run {argAliasFilePath, parameters}
  
  ##ファイルパス
  set strFilePath to (POSIX path of argAliasFilePath) 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 strResponseText to ocidURL as text
  ########################
  ##ダイアログ
  ########################
  set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns" as alias
  
  #前面に
  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 strTitle to ("戻り値です") as text
  set strMes to ("戻り値です
値のコピーができます") as text
  set recordResult to (display dialog strMes with title strTitle default answer strResponseText buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" giving up after 30 with icon aliasIconPath without hidden answer)
  if (gave up of recordResult) is true then
return "時間切れです"
  else if (button returned of recordResult) is "キャンセル" then
return "キャンセルです"
  else if button returned of recordResult is "クリップボードにコピー" then
    set strReturnedText to (text returned of recordResult) as text
    set aliasIconPath to POSIX file "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strReturnedText))
appPasteboard's clearContents()
    set boolDone to appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
    if boolDone = false then
      try
        tell application "Finder"
          set the clipboard to strReturnedText as text
        end tell
      on error
return false
      end try
    else if boolDone = true then
return true
    end if
    
    if boolDone is false then
log ("ペーストボードへのコピーに失敗しました") as text
return "ペーストボードへのコピーに失敗しました"
    end if
  else
log (text returned of recordResult) as text
  end if
  
end run


|

[workflow]ミュージックファイルの曲名とアーティスト名をコピーする

ダウンロード - copy2songtitle.workflow.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 "AVFoundation"
use framework "AppKit"
use framework "CoreMedia"
use scripting additions
property refMe : a reference to current application


on run ({argListFilePath, argScript})
  set strDefaultAnswer to "" as text
  set numCntFile to (count of argListFilePath) as integer
  set numCnt to 1 as integer
  repeat with itemAliasFilePath in argListFilePath
    ###パス
    set strFilePath to (POSIX path of itemAliasFilePath) as text
    set ocidFilePath to (refMe's NSString's stringWithString:strFilePath)
    set ocidFilePath to ocidFilePath's stringByExpandingTildeInPath()
    set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false)
    ##
    set strArtist to doGetArtistName(ocidFilePathURL) as text
    set strTitle to doGetTitle(ocidFilePathURL) as text
    if numCntFile = 1 then
      set strDefaultAnswer to (strTitle & " - " & strArtist) as text
    else if numCntFile = numCnt then
      set strDefaultAnswer to (strDefaultAnswer & (strTitle & " - " & strArtist)) as text
    else
      set strDefaultAnswer to (strDefaultAnswer & (strTitle & " - " & strArtist) & "
") as text
    end if
    set numCnt to numCnt + 1 as integer
  end repeat
  ##############################
  #####ダイアログ
  ##############################
  ##前面に出す
  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 aliasIconPath to POSIX file "/System/Applications/Music.app/Contents/Resources/AppIcon.icns" as alias
  set strMes to (strDefaultAnswer) as text
  set recordResult to (display dialog strMes with title "選んでください" default answer strDefaultAnswer buttons {"クリップボードにコピー", "キャンセル", "OK"} default button "OK" cancel button "キャンセル" giving up after 20 with icon aliasIconPath without hidden answer)
  ###クリップボードコピー
  if button returned of recordResult is "クリップボードにコピー" then
    set strText to (text returned of recordResult) 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
  end if
end run

###########################################
### アーティスト名を読み取るサブ
###########################################

to doGetArtistName(argURL)
  ###URLアセットを取得
  set ocidAVURLAsset to refMe's AVURLAsset's URLAssetWithURL:argURL options:(missing value)
  ###メタデータを取得
  set ocidCommonMetadata to ocidAVURLAsset's commonMetadata()
  ###AVMetadataCommonKeyArtistメタデータを取得
  set ocidTitleArray to refMe's AVMetadataItem's metadataItemsFromArray:ocidCommonMetadata withKey:(refMe's AVMetadataCommonKeyArtist) keySpace:(refMe's AVMetadataKeySpaceCommon)
  set ocidMetaArtist to ocidTitleArray's objectAtIndex:0
  set strMetaArtist to ocidMetaArtist's |value|() as text
return (strMetaArtist)
end doGetArtistName

###########################################
### タイトルを読み取る
###########################################
to doGetTitle(argURL)
  ###URLアセットを取得
  set ocidAVURLAsset to refMe's AVURLAsset's URLAssetWithURL:argURL options:(missing value)
  ###メタデータを取得
  set ocidCommonMetadata to ocidAVURLAsset's commonMetadata()
  ###AVMetadataCommonKeyTitleメタデータを取得
  set ocidTitleArray to refMe's AVMetadataItem's metadataItemsFromArray:ocidCommonMetadata withKey:(refMe's AVMetadataCommonKeyTitle) keySpace:(refMe's AVMetadataKeySpaceCommon)
  set ocidMetaTitle to ocidTitleArray's objectAtIndex:0
  set strTitle to ocidMetaTitle's |value|() as text
return (strTitle)
end doGetTitle

|

[Automator]Adobe Bridge 2024で開く

ダウンロード - openbridge14.workflow.zip


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# Automator ワークフロー用 (クイックアクション)
# ワークフローが受け取るのは『フォルダ』 アプリケーションは『Finder』
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use scripting additions

on run {input}
  set strBundleID to "com.adobe.bridge14" as text
  ####フォルダの数だけ繰り返し
  repeat with itemFolderPath in input
    ######パス フォルダのエイリアス
    set aliasDirPath to itemFolderPath as alias
    ###入力のフォルダのエイリアスをアプリで開く
    tell application id strBundleID to launch
    tell application id strBundleID
      open aliasDirPath
    end tell
  end repeat
end run

|

[workflow用]イメージピクセルサイズのCSSをクリップボードにコピー


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

use AppleScript version "2.8"
use scripting additions
use framework "Foundation"
use framework "AppKit"
property refMe : a reference to current application


property numYpx : 0
property numXpx : 0

on run {argAliasFilePath}
  set strFilePath to (POSIX path of argAliasFilePath) as text
  set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
  set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
  set objImageRep to (refMe's NSBitmapImageRep's imageRepWithContentsOfFile:(ocidFilePath))
  tell objImageRep
    set numXpx to pixelsHigh()
    set numYpx to pixelsWide()
  end tell
  set strResponse to "width:" & numYpx & "px;height:" & numXpx & "px;" as text
  set the clipboard to strResponse as text
end run

|

その他のカテゴリー

Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager 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 Diff AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript Droplet AppleScript eMail AppleScript Encode % AppleScript Encode Decode AppleScript Encode UTF8 AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript Guide AppleScript HTML AppleScript HTML Entity AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim AppleScript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript Leading Zero AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript Mail AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Messages AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSArray Sort 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 NSGraphicsContext 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 NSpoint AppleScript NSPredicate AppleScript NSPrintOperation AppleScript NSRange AppleScript NSRect 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 NSURLSession AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotation AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFImageRep AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photoshop AppleScript Pictures 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 Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript Swift AppleScript System Events AppleScript System Events Plist AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text MD 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 Applications CityCode github iPhone List lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom Windows zoom