Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

カテゴリー: Spotlight

Keynoteの表の中に入っている1列目のデータをもとにフォルダ検索して値を返す

Posted on 3月 6, 2021 by Takaaki Naganoya

Keynoteの表の中に入っている1列目のデータをもとに、指定ルートフォルダ以下のサブフォルダを指定して、その下位フォルダに存在しているAppleScript書類の数をSpotlightでかぞえ、表の2列目に書き戻すAppleScriptです。

新著「Cocoa Scripting Course #1」の付録Scriptについて、各フォルダに入っているScript書類をかぞえて表に入れておく必要がありました。ただ、内容をアップデートするたびに書き換える必要があるので、自動でカウントして表に書き込むScriptを用意しました。

実行にはShane Stanleyの「Metadata Lib」を必要とします。実行にはScript Debuggerも必要です。Keynoteで表の入ったスライドを表示している必要もあります。表の1列目に書かれたサブフォルダ名を指定して、それぞれ含まれている書類数をカウントして表に書き戻します。


▲初期状態


▲カウント対象フォルダ。AppleScript書類がフラット形式とバンドル形式の2つが混在して入っている


▲書類数をかぞえるルートフォルダを指定。表の1列目にかかれているフォルダ名と連結して、その下をすべてSpotlightで検索してファイルの存在確認を行う


▲すべてカウントして表に書き戻したところ

AppleScript名:表の中に入っている1列目のデータをもとにフォルダ検索して値を返す.scptd
—
–  Created by: Takaaki Naganoya
–  Created on: 2021/03/05
—
–  Copyright © 2021 Piyomaru Software, All Rights Reserved
—

use AppleScript version "2.7" — High Sierra (10.13) or later
use framework "Foundation"
use scripting additions
use mdLib : script "Metadata Lib" version "2.0.0"

–カウントするAppleScript書類が入っているフォルダのルートフォルダを指定
set origPath to POSIX path of (choose folder with prompt "Select Target folder")

tell application "Keynote"
  tell front document
    tell current slide
      –現在のスライド上の表を取得
      
set tList to every table
      
      
–表オブジェクトでループ
      
repeat with i in tList
        
        
–表オブジェクトの情報取得
        
tell i
          set colCount to column count
          
set rowCount to row count
          
set headerCount to header row count
          
set footerCount to footer row count
          
          
          
–表のセル内データを取得して2D Arrayにまとめる
          
set newList to {}
          
repeat with y from 1 to rowCount
            tell row y
              set cList to value of every cell
              
set tmpL to {}
              
              
repeat with ii in cList
                set jj to contents of ii
                
if jj = missing value then set jj to "" –空欄はmissing valueが返ってくるのでヌルストリングに差し替え
                
set the end of tmpL to jj
              end repeat
              
              
set the end of newList to tmpL
            end tell
          end repeat
          
          
          
–Keynoteの表データ1列目の情報をもとに、実際のフォルダの中のAppleScript書類を検索してカウントしてlistに記入
          
set new2List to items (headerCount + 1) thru -1 of newList
          
repeat with ii in new2List
            copy ii to oneLine
            
set targFolName to first item of oneLine
            
set tmpTarg to origPath & "/" & targFolName & "/"
            
            
–Spotlight検索でファイルを取得する
            
set aResList to perform search in folders {tmpTarg} predicate string "kMDItemContentType == %@ || kMDItemContentType == %@" search arguments {"com.apple.applescript.script", "com.apple.applescript.script-bundle"} –フラット形式書類とバンドル形式書類を検索
            
            
set scrCount to length of aResList –書類数をカウント
            
set last item of ii to scrCount
          end repeat
          
          
          
–Keynoteの表にデータを書き戻す
          
repeat with y from 1 to (length of new2List)
            tell row (y + 1)
              set aDat to contents of item y of new2List
              
repeat with x from 1 to length of aDat
                
                
–非同期実行モード(倍速処理)
                
ignoring application responses
                  tell cell x
                    set its value to contents of (item x of aDat)
                  end tell
                end ignoring
                
              end repeat
            end tell
          end repeat
          
        end tell
      end repeat
    end tell
  end tell
end tell

★Click Here to Open This Script 

Posted in file list Spotlight | Tagged 10.14savvy 10.15savvy 11.0savvy Keynote | 1 Comment

指定フォルダ以下のアプリケーションを取得して、Scriptabilityをチェック

Posted on 9月 11, 2019 by Takaaki Naganoya

指定フォルダ以下のアプリケーションをSpotlightで検索して、それらのうちAppleScript対応の(Scriptableな)ものを集計するAppleScriptです。

Shane StanleyのMetadata Libを呼び出してSpotlight検索を行い、アプリケーションファイルの一覧を取得。その後、各アプリケーションのInfo.plistの情報を取得してNSAppleScriptEnabled=trueのアプリケーションのパスをlist(array)に追加します。

ただし、一部のApple製のアプリケーションに見られるように、NSAppleScriptEnabled=trueであるにもかかわらず、実際のAppleScriptサポート機能が実装されていないものもありますので(例:iBooks Author)これだけではScript対応かどうかの完全な判断は行えません。

一方、AppleScriptなどのOSA言語によるコントロールに対応していないアプリケーションはこれで完全にフィルタできます。NSAppleScriptEnabledのエントリがInfo.plistに存在しないものは非対応アプリケーションです。

非対応のアプリケーションに対して、AppleScriptからは起動、終了、ファイルのオープン、印刷などの基礎的な操作やアプリケーションの情報取得(名称やバージョンなど)、Finder経由で指定書類をアプリケーションでオープン、ぐらいの操作。また、GUI Scriptingによるメニューやボタンの強制操作しかできません。

AppleScript名:指定フォルダ以下のアプリケーションを取得して、Scriptabilityをチェック.scptd
— Created 2019-09-11 by Takaaki Naganoya
— 2019 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use mdLib : script "Metadata Lib" version "2.0.0" –https://macosxautomation.com/applescript/apps/Script_Libs.html

set origPath to POSIX path of (choose folder default location (path to applications folder))
set aResList to mdLib’s searchFolders:{origPath} searchString:("kMDItemContentType == %@") searchArgs:{"com.apple.application-bundle"}

set allCount to length of aResList
set sList to {}

repeat with i in aResList
  set j to contents of i
  
set sRes to retAppScriptabilityFromBundleIPath(j) of me
  
if sRes = true then
    set the end of sList to j
  end if
end repeat

return (length of sList)
–> 297

–指定パスからアプリケーションのScriptabilityをbooleanで返す
on retAppScriptabilityFromBundleIPath(appPath as string)
  set aDict to (current application’s NSBundle’s bundleWithPath:appPath)’s infoDictionary()
  
set aRes to aDict’s valueForKey:"NSAppleScriptEnabled"
  
if aRes = missing value then return false
  
return aRes as boolean
end retAppScriptabilityFromBundleIPath

★Click Here to Open This Script 

Posted in file list Spotlight | Tagged 10.12savvy 10.13savvy 10.14savvy NSBundle | Leave a comment

ハッシュ値から、メモリースティックに保存されたReplay Dataのステージ名とプレイ日時を求める v3

Posted on 10月 30, 2018 by Takaaki Naganoya

PSPのゲーム「戦場の絆ポータブル」のセーブデータについているステージ別のプレビュー画像のハッシュ値から対戦ステージと対戦日時を抽出してタブ区切りテキストで出力するAppleScriptです。

保存された対戦データの内容を集計するために作成したものです。

PSPでメモリースティックに保存された対戦データには、すべて同じファイル名(ICON0.PNG)で異なる画像が添付されていました。ファイル名で対戦ステージを判定しようにも同じファイル名なので区別できません。

そこで、Spotlightの機能を用いて各セーブデータの「ICON0.PNG」をピックアップし、画像の内容のハッシュ値(SHA-1)を計算して、対戦ステージ内容を判定しました。

直近の対戦データをメモリースティック経由でMacに読み込み、本Scriptで分析してみたところ、

ジャブロー地上	2017年9月18日月曜日 14:42:48
ジャブロー地上	2017年9月18日月曜日 14:50:02
ジャブロー地上	2017年9月18日月曜日 14:55:22
タクラマカン砂漠	2017年9月18日月曜日 15:02:32
サイド7	2017年9月18日月曜日 15:09:36
ジャブロー地下	2017年9月18日月曜日 15:17:06
ジャブロー地上	2017年9月18日月曜日 15:31:08
サイド7	2017年9月18日月曜日 15:38:28
ジャブロー地上	2017年9月18日月曜日 15:51:52
ジャブロー地上	2018年1月2日火曜日 16:13:30
サイド7	2018年1月2日火曜日 16:23:04
ジャブロー地下	2018年1月2日火曜日 16:57:22

のようになりました。正月と秋分の日に親戚で集まったときに甥っ子と対戦した様子がありありと記録されています。

本Scriptはたまたまゲームのセーブデータの集計を行っていますが、同様の形式のデータを集計したい場合には使えそうです。

–> md5Lib.framework(To ~/Library/Frameworks)

AppleScript名:チェックサム値から、メモリースティックに保存されたReplay Dataのステージ名とプレイ日時を求める v3.1
— Created 2015-04-17 by Takaaki Naganoya
— Modified 2018-10-29 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "md5Lib" –https://github.com/JoeKun/FileMD5Hash
use bPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html
use mdLib : script "Metadata Lib" version "2.0.0" –https://www.macosxautomation.com/applescript/apps/

property FileHash : a reference to current application’s FileHash
property SMSForder : a reference to current application’s SMSForder
property NSPredicate : a reference to current application’s NSPredicate
property NSFileManager : a reference to current application’s NSFileManager
property NSMutableArray : a reference to current application’s NSMutableArray

–各SAVEDATAフォルダ中の「ICON0.PNG」のSHA-1ハッシュ値とステージ名の対応表
set shaArray to NSMutableArray’s arrayWithArray:{{stageName:"ニューヤーク", sha1:"dbb9e8e26e96dbb4dd3198e55b6cde41aba8e0a8"}, {stageName:"鉱山都市", sha1:"72f35456504b1957ec85fb6a1597ac1a2baa2ee9"}, {stageName:"グレートキャニオン", sha1:"9de93e8b853fe153bc73066fb07481c774499960"}, {stageName:"サイド7", sha1:"be22fa949bfd78b0cd97596929f07ce4ec501d7b"}, {stageName:"タクラマカン砂漠", sha1:"5284dc5f0f7a53ee5677908f66da1e00b80f76b6"}, {stageName:"トリントン・タワー", sha1:"9f080853dac45ecaf1672ff2230f2b9a80a00eb4"}, {stageName:"ジャブロー地下", sha1:"a93550099419f52444cf77366773192d0bf5f848"}, {stageName:"ヒマラヤ", sha1:"877f998d608dd267c380e59a17b2a95a139baef5"}, {stageName:"ジャブロー地上", sha1:"8c4ee44e8f2fbcbf061e6d5ea2b202b08f42c59a"}}

load framework

set apPath1 to choose folder with prompt "リプレイデータが入っているフォルダを選択してください"
set aRes to perform search in folders {apPath1} predicate string "kMDItemFSName == %@" search arguments {"ICON0.PNG"}

set outList to {}
set errorList to {}

repeat with i in aRes
  set j to contents of i
  
set sumRes to (FileHash’s sha1HashOfFileAtPath:(j)) as string
  
  
–チェックサムからステージ名を検索する
  
set aPredStr to "sha1 == ’" & sumRes & "’"
  
set aPredicate to (NSPredicate’s predicateWithFormat:aPredStr)
  
set filteredArray to (shaArray’s filteredArrayUsingPredicate:aPredicate)
  
  
if filteredArray as list = {} then
    set the end of errorList to j
  else
    set tmpStage to (filteredArray’s valueForKey:"stageName") as string
    
    
set fAttrib to (NSFileManager’s defaultManager()’s attributesOfItemAtPath:j |error|:(missing value))
    
set cDat to (fAttrib’s fileCreationDate()) as date
    
    
set tmpList to {tmpStage, cDat}
    
    
if tmpList is not in outList then
      set the end of outList to tmpList
    end if
  end if
end repeat

–2D Listのソート
set sortIndexes to {1} –Key Item id: begin from 0
set sortOrders to {true} –ascending = true
set sortTypes to {"compare:"}
set out2List to (SMSForder’s subarraysIn:(outList) sortedByIndexes:sortIndexes ascending:sortOrders sortTypes:sortTypes |error|:(missing value)) as list

–2D Listをタブ区切りテキストに変換して返す
set aText to retItemDelimedAndParagraphDelimedText(out2List, tab, return) of me

–入れ子のリストを、アイテム間のデリミタとパラグラフ間のデリミタを指定してテキスト化
–というか、入れ子のリストをタブ区切りテキストにするのが目的
on retItemDelimedAndParagraphDelimedText(aList, itemDelim, paragraphDelim)
  set aText to ""
  
  
repeat with i in aList
    set aStr to retDelimedText(i, itemDelim) of me
    
set aText to aText & aStr & paragraphDelim
  end repeat
  
  
return aText
end retItemDelimedAndParagraphDelimedText

on retDelimedText(aList, aDelim)
  set aText to ""
  
set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to aDelim
  
set aText to aList as text
  
set AppleScript’s text item delimiters to curDelim
  
return aText
end retDelimedText

★Click Here to Open This Script 

Posted in file File path list Record Spotlight | Tagged 10.11savvy 10.12savvy NSFileManager NSMutableArray NSPredicate | Leave a comment

Google Drive File StreamのドライブでSpotlight Indexを生成

Posted on 8月 4, 2018 by Takaaki Naganoya

Google Drive File Stream上でSpotlight Indexを生成するAppleScriptです。

Google Driveには、Gmailのオマケでついてくる個人のデバイス間で情報のシンクロを行う目的のPersonal版(DropboxのGoogle版的なもの)と、企業内やグループ内でファイル共有を行うG SuiteのGoodle Drive File Streamがあり、後者についてはGoogleによる「Google Drive File Stream」ツールが提供され、GoogleDriveをデスクトップにマウントできます。

実際にGoogle Drive File Streamを使ってみたところ、デフォルト状態だとSpotlight検索が効きませんでした。

そこで、Index生成してみたものの…既存のファイルについてはSpotlight検索できませんでした。Index生成後に、新規追加したファイルについてはSpotlight検索が有効でした。

後日談:ただ、Google Drive File Streamに対してSpotlight Indexを常時生成するようにすると、CPUに対する負荷が大きくなるため、実際の運用ではSpotlightを無効にして運用するようにしました。

AppleScript名:Google Drive File Streamでインデックス生成
do shell script "mdutil -E /Volumes/GoogleDrive/" with administrator privileges

★Click Here to Open This Script 

自分が試したのは、Google Drive File Stream内の「マイドライブ」領域のみで、

「グループドライブ」領域についてはまだテストできていません。

既存のファイルについては、mdimportコマンドでインデックス作成すれば大丈夫だと思っていますが、実際に試してみると予想外の挙動を行うのかもしれません。

AppleScript名:GDFS上でSpotlight検索
— Created 2016-06-17 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property NSArray : a reference to current application’s NSArray
property NSPredicate : a reference to current application’s NSPredicate
property NSSortDescriptor : a reference to current application’s NSSortDescriptor
property NSMetadataQuery : a reference to current application’s NSMetadataQuery
property NSNotificationCenter : a reference to current application’s NSNotificationCenter
property NSMetadataQueryDidUpdateNotification : a reference to current application’s NSMetadataQueryDidUpdateNotification
property NSMetadataQueryDidFinishGatheringNotification : a reference to current application’s NSMetadataQueryDidFinishGatheringNotification

property searchRes : {}

set origPath to POSIX path of (choose folder)
set aList to spotlightSearch(origPath, "kMDItemContentType == ’public.png’") of me

on spotlightSearch(origPath, aMDfindParam)
  
  
set my searchRes to {} –initialize
  
initiateSearchForFullPath(aMDfindParam, origPath) –Predicate & Scope Directory
  
  
–Waiting for the result
  
repeat while my searchRes = {}
    delay 0.01
  end repeat
  
  
set anObj to my searchRes’s firstObject() –Pick up the first one for test
  
if anObj = missing value then return {} –No Result
  
  
set resArray to {}
  
repeat with anItem in my searchRes
    set j to contents of anItem
    
set aPath to (j’s valueForAttribute:"kMDItemPath") as string
    
set the end of resArray to aPath
  end repeat
  
  
return resArray
  
end spotlightSearch

on initiateSearchForFullPath(aQueryStrings, origPath)
  
  
set aSearch to NSMetadataQuery’s alloc()’s init()
  
  
NSNotificationCenter’s defaultCenter()’s addObserver:(me) selector:"queryDidUpdate:" |name|:(NSMetadataQueryDidUpdateNotification) object:aSearch
  
NSNotificationCenter’s defaultCenter()’s addObserver:(me) selector:"initalGatherComplete:" |name|:(NSMetadataQueryDidFinishGatheringNotification) object:aSearch
  
  
set aPredicate to NSPredicate’s predicateWithFormat:aQueryStrings
  
aSearch’s setPredicate:aPredicate
  
  
set aScope to NSArray’s arrayWithObjects:{origPath}
  
aSearch’s setSearchScopes:aScope
  
  
set sortKeys to NSSortDescriptor’s sortDescriptorWithKey:"kMDItemFSName" ascending:true
  
aSearch’s setSortDescriptors:(NSArray’s arrayWithObject:sortKeys)
  
  
aSearch’s startQuery()
  
end initiateSearchForFullPath

on queryDidUpdate:sender
  log sender
  
–> (NSConcreteNotification) NSConcreteNotification 0x7fa618450820 {name = NSMetadataQueryDidFinishGatheringNotification; object = <NSMetadataQuery: 0x7fa6172c6ca0>}
end queryDidUpdate:

on initalGatherComplete:sender
  set anObject to sender’s object
  
anObject’s stopQuery()
  
NSNotificationCenter’s defaultCenter()’s removeObserver:me |name|:(NSMetadataQueryDidUpdateNotification) object:anObject
  
NSNotificationCenter’s defaultCenter()’s removeObserver:me |name|:(NSMetadataQueryDidFinishGatheringNotification) object:anObject
  
  
set my searchRes to anObject’s results()
end initalGatherComplete:

★Click Here to Open This Script 

Posted in drive file shell script Spotlight | Tagged 10.12savvy NSArray NSMetadataQuery NSNotificationCenter NSPredicate NSSortDescriptor | Leave a comment

HoudahSpotのコントロールを行う

Posted on 6月 1, 2018 by Takaaki Naganoya

HoudahSpotの各種コントロールを行うAppleScriptです。

HoudahSpotは、Spotlightの検索を行うアプリケーションで、AppleScript対応しています。

検索自体は非同期で実行され、検索が終了したかどうかは最前面のドキュメント(front document)のプロパティ「search completed」がtrueになるかどうかをループで確認することになります。このさい、delayコマンドで時間待ちしないと負荷が高くなって全体のパフォーマンスが低下するので、0.1秒ぐらいの時間待ちを行うのが非同期アプリケーションのコントロール時の「お約束」です(Xcodeとか)。

HoudahSpotの検索条件についてはAppleScriptから一切コントロールできないので、HoudahSpot書類に保存しておいてオープンして再検索を行うという利用スタイルを考えているのでしょう。

みどころは、Finderの最前面のウィンドウのパス以下を対象にSpotlight検索するfinder searchコマンド。ちょっと目の付け所がいいと思います。あと、HoudahSpot HelperをオンにするとStatus Bar上にmacOS純正のSpotlightアイコンと同様のアイコンが出てきて検索できます。これもいいと思います。

ただ、わざわざGUIアプリケーションで実行しなくても、AppleScriptから直接Spotlightの機能を呼び出せるので、HoudahSpotを利用する必然性があまり感じられません。

AppleScript名:アプリケーションのプロパティを取得する
tell application "HoudahSpot"
  properties
  
–> {frontmost:false, class:application, name:"HoudahSpot", version:"4.3.7"}
end tell

★Click Here to Open This Script 

AppleScript名:ドキュメントのプロパティを取得する
tell application "HoudahSpot"
  tell document 1
    properties
    
–> {modified:false, name:"Untitled", details pane visible:false, search completed:false, selection:{}, search active:false, file:missing value, results view:list view, search pane visible:true, class:document}
  end tell
end tell

★Click Here to Open This Script 

AppleScript名:ドキュメントをかぞえる
tell application "HoudahSpot"
  set dCount to count every document
  
–> 1
end tell

★Click Here to Open This Script 

AppleScript名:Windowのプロパティを取得する
tell application "HoudahSpot"
  tell window 1
    properties
    
–> {zoomable:true, closeable:true, current tab:tab 1 of window id 89717 of application "HoudahSpot", zoomed:false, class:window, index:1, visible:true, sidebar visible:false, name:"Untitled", toolbar visible:true, miniaturizable:true, id:89717, miniaturized:false, resizable:true, bounds:{0, 22, 1407, 797}, document:document "Untitled" of application "HoudahSpot"}
    
  end tell
end tell

★Click Here to Open This Script 

AppleScript名:WindowのTabをかぞえる
tell application "HoudahSpot"
  tell window 1
    set tCount to count every tab
    
–> 1
  end tell
end tell

★Click Here to Open This Script 

AppleScript名:検索を実行
tell application "HoudahSpot"
  search "Piyowolf"
  
–> document "Untitled 3" of application "HoudahSpot"
end tell

★Click Here to Open This Script 

AppleScript名:検索結果のプロパティをすべて取得する
tell application "HoudahSpot"
  set resList to every result of front document
  
  
set rList to {}
  
repeat with i in resList
    set aRes to properties of i
    
log aRes
    
(*class:result, path:/Users/maro/Library/Mail/V4/DA40FA88-F9E4-45A0-A3C9-4DCD4DCE3C38/Sent Messages.mbox/8DD46D63-E6F7-4A3C-81DF-4D4FDBFBE19B/Data/7/9/0/2/Messages/2097257.emlx, id:/Users/maro/Library/Mail/V4/DA40FA88-F9E4-45A0-A3C9-4DCD4DCE3C38/Sent Messages.mbox/8DD46D63-E6F7-4A3C-81DF-4D4FDBFBE19B/Data/7/9/0/2/Messages/2097257.emlx, name: Yasu for Mac*)
  end repeat
end tell

★Click Here to Open This Script 

AppleScript名:検索結果をカウントする
tell application "HoudahSpot"
  set resCount to count every result of front document
end tell

★Click Here to Open This Script 

AppleScript名:キーワード検索して結果を取得する
tell application "HoudahSpot"
  set resDoc to search "AppleScriptObjC"
  
  
repeat
    tell resDoc
      set resC to search completed
    end tell
    
if resC is equal to true then exit repeat
    
delay 0.1
  end repeat
  
  
set resList to count every result of front document
end tell

★Click Here to Open This Script 

AppleScript名:検索結果からフィルタ参照でしぼりこみ
tell application "HoudahSpot"
  set resList to every result of front document whose path ends with ".md"
end tell

★Click Here to Open This Script 

AppleScript名:検索結果を指定パスに保存する
set aSavePath to choose file name

tell application "HoudahSpot"
  save front document in aSavePath
end tell

★Click Here to Open This Script 

AppleScript名:保存しておいた検索結果をオープンする
set aFile to choose file

tell application "HoudahSpot"
  open aFile
end tell

★Click Here to Open This Script 

AppleScript名:キーワードをFinderの最前面のウィンドウのパスを対象に検索
tell application "HoudahSpot"
  set resDoc to finder search "EXIF"
  
  
repeat
    tell resDoc
      set resC to search completed
    end tell
    
if resC is equal to true then exit repeat
    
delay 0.1
  end repeat
  
  
set resList to count every result of front document
  
end tell

★Click Here to Open This Script 

Posted in Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy HoudahSpot | Leave a comment

自然言語で指定した日時以降に作成されたファイルをSpotlight検索

Posted on 5月 3, 2018 by Takaaki Naganoya
AppleScript名:自然言語で指定した日時以降に作成されたファイルをSpotlight検索
— Created 2017-09-21 by Takaaki Naganoya
— Modified 2017-09-22 by Shane Stanley
— 2017 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use mdLib : script "Metadata Lib" version "2.0.0"

property NSString : a reference to current application’s NSString
property NSDataDetector : a reference to current application’s NSDataDetector
property NSTextCheckingTypeDate : a reference to current application’s NSTextCheckingTypeDate

set aDate to getDatesIn("先週の月曜日") of me –"last Monday" in Japanese
log aDate

set thePath to POSIX path of (path to desktop)

set theFiles to mdLib’s searchFolders:{thePath} searchString:("kMDItemFSCreationDate >= %@") searchArgs:{aDate}
–> returns POSIX path list

on getDatesIn(aString)
  set anNSString to NSString’s stringWithString:aString
  
set theDetector to NSDataDetector’s dataDetectorWithTypes:(NSTextCheckingTypeDate) |error|:(missing value)
  
set theMatch to theDetector’s firstMatchInString:anNSString options:0 range:{0, anNSString’s |length|()}
  
if theMatch = missing value then error "No date found with String:" & aString
  
set theDate to theMatch’s |date|()
  
return theDate as date
end getDatesIn

★Click Here to Open This Script 

Posted in Calendar file Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Markdownのimglinkタグ行のリンク書き換え

Posted on 5月 3, 2018 by Takaaki Naganoya

Markdown書類からリンクしているローカルの画像(相対パス表記)へのリンクを書き換えるAppleScriptです。

MacDownが画像リンクの管理などは一切してくれないので、自前で(AppleScriptで)書き換えを行なっています。

ルートフォルダはフォルダ名が「–」ではじまるようにルールを(勝手に)決めており、各Markdown書類フォルダをさらに細分化した場合には、Markdown書類から画像フォルダへの相対パス指定が合わなくなってしまいます。

そこで、画像フォルダを求めてMarkdown書類の画像リンクを再計算して書き換えてみました。画像自体をルートフォルダからSpotlightで検索するようにしてもよいのですが、今回はとりあえずルールを自分で決めて自分で守っているので、このように処理してみました。

ただ、いまだにリンク画像のパスを手で書かされる(記述自体はAppleScriptでその場で計算しているので完全手書きではないですが)のには、いささかMarkdownの仕様の素朴さに呆れてしまうところです、、、、

AppleScript名:Markdownのimglinkタグ行のリンク書き換え
— Created 2017-01-26 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use mdLib : script "Metadata Lib" version "2.0.0" –https://www.macosxautomation.com/applescript/apps/

property NSArray : a reference to current application’s NSArray
property NSString : a reference to current application’s NSString
property NSScanner : a reference to current application’s NSScanner
property NSPredicate : a reference to current application’s NSPredicate
property NSDictionary : a reference to current application’s NSDictionary
property NSMutableArray : a reference to current application’s NSMutableArray
property NSDataDetector : a reference to current application’s NSDataDetector
property NSAttributedString : a reference to current application’s NSAttributedString
property NSUTF8StringEncoding : a reference to current application’s NSUTF8StringEncoding
property NSTextCheckingTypeLink : a reference to current application’s NSTextCheckingTypeLink

set origPath to POSIX path of (choose folder with prompt "Markdown書類が入っているフォルダを選択")
set savePath to POSIX path of (choose folder with prompt "画像フォルダを選択")

set tmp2 to NSString’s stringWithString:savePath
set tmp3 to (tmp2’s lastPathComponent()) as string

–Spotlightで指定フォルダ以下のMarkdown書類を検索
set aRes to mdLib’s searchFolders:{origPath} searchString:("kMDItemKind == %@ ") searchArgs:{"Markdown Document"}

repeat with i in aRes
  
  
–テキストエンコーディングをUTF-8でMarkDown書類テキスト読み込み
  
set aText to (NSString’s stringWithContentsOfFile:(i) encoding:(NSUTF8StringEncoding) |error|:(missing value)) as string
  
  
–Markdown記法の画像タグが入っている場合のみ処理
  
set repLinkURLs to {} –パス置換対象リスト(oldPath, newPathでペア)
  
  
set aFreq to retFrequency(aText, "![") of me
  
  
if aFreq is not equal to 0 then
    set bList to parseStringParagraphs(NSString’s stringWithString:aText) of me
    
set aPredicates to NSPredicate’s predicateWithFormat_("SELF BEGINSWITH[cd] %@", "![")
    
set cList to (bList’s filteredArrayUsingPredicate:aPredicates) as list
    
    
–画像ダウンロードおよび、ダウンロードずみ画像への相対パスの計算ループ
    
repeat with ii in cList
      set jj to contents of ii –画像リンクのMarkdownタグ行
      
set tmpLinkPath to parseStrFromTo(jj, "(", ")") of me
      
      
set aStr to (NSString’s stringWithString:((contents of i) as string))
      
set aList to (aStr’s stringByDeletingLastPathComponent’s pathComponents()) as list of string or string
      
      
set aLen to length of aList
      
      
–リンク画像の相対パスを絶対パスに変換する
      
set rStr to (NSString’s stringWithString:tmpLinkPath)
      
set r2Str to rStr’s stringByDeletingLastPathComponent’s lastPathComponent() –フォルダ名(="9999_images")
      
set r3Str to (rStr’s lastPathComponent()) as string –ファイル名(="fake_scriptable.png")
      
      
–書籍のルートフォルダを求め、その直下にある画像フォルダを名指しで指定
      
repeat with i2 from aLen to 0 by -1
        set j to contents of (item i2 of aList)
        
if j begins with "–" then
          exit repeat
        end if
      end repeat
      
      
set f1Path to (items 1 thru i2 of aList) & r2Str & r3Str
      
set f2Path to (NSString’s pathWithComponents:f1Path) as string
      
      
–MarkDown書類と移動先の画像フォルダ中の画像の相対パスを求める
      
set newRelPath to calcRelativePathFromTwoAbsolutePaths(i, f2Path) of me
      
      
set the end of repLinkURLs to {tmpLinkPath, newRelPath}
      
    end repeat
    
    
–リンク書き換え
    
copy aText to bText
    
repeat with ii in repLinkURLs
      copy ii to {oldPath, newPath}
      
set bText to repChar(bText, oldPath, newPath) of me
    end repeat
    
    
–もともとのパスにMarkdown書類を上書き保存
    
set writeString to (NSString’s stringWithString:bText)
    
set ssRes to (writeString’s writeToFile:i atomically:true encoding:(NSUTF8StringEncoding) |error|:(missing value))
    
  end if
end repeat

–指定文字列内の指定キーワードの出現回数を取得する
on retFrequency(origText, aKeyText)
  set aRes to parseByDelim(origText, aKeyText) of me
  
return ((count every item of aRes) – 1)
end retFrequency

on parseByDelim(aData, aDelim)
  set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to aDelim
  
set dList to text items of aData
  
set AppleScript’s text item delimiters to curDelim
  
return dList
end parseByDelim

–テキストを行ごとにparseしてNSArrayに
on parseStringParagraphs(anNSString)
  set anArray to NSMutableArray’s alloc()’s init()
  
set aRange to current application’s NSMakeRange(0, anNSString’s |length|())
  
  
repeat while aRange’s |length|() > 0
    set subRange to anNSString’s lineRangeForRange:(current application’s NSMakeRange(aRange’s location(), 0))
    
    
–行が改行コードまで取得されるので、改行コードを除外するように微調整
    
copy subRange to tmpRange
    
set tmpRange’s |length| to ((subRange’s |length|()) – 1) –微調整
    
set aLine to anNSString’s substringWithRange:tmpRange
    
anArray’s addObject:aLine
    
    
set aRange’s location to (current application’s NSMaxRange(subRange))
    
set aRange’s |length| to ((aRange’s |length|()) – (subRange’s |length|()))
  end repeat
  
  
return anArray
end parseStringParagraphs

on repChar(origText, targStr, repStr)
  set {txdl, AppleScript’s text item delimiters} to {AppleScript’s text item delimiters, targStr}
  
set temp to text items of origText
  
set AppleScript’s text item delimiters to repStr
  
set res to temp as text
  
set AppleScript’s text item delimiters to txdl
  
return res
end repChar

on parseStrFromTo(aParamStr, fromStr, toStr)
  set theScanner to NSScanner’s scannerWithString:aParamStr
  
set anArray to NSMutableArray’s array()
  
  
repeat until (theScanner’s isAtEnd as boolean)
    — terminate check, return the result (aDict) to caller
    
set {theResult, theKey} to theScanner’s scanUpToString:fromStr intoString:(reference)
    
    
— skip over separator
    
theScanner’s scanString:fromStr intoString:(missing value)
    
set {theResult, theValue} to theScanner’s scanUpToString:toStr intoString:(reference)
    
if theValue is missing value then set theValue to "" –>追加
    
    
— skip over separator
    
theScanner’s scanString:toStr intoString:(missing value)
    
    
anArray’s addObject:theValue
  end repeat
  
  
if (anArray’s |count|()) as integer = 1 then
    return theValue as list of string or string
  else
    return anArray as list
  end if
end parseStrFromTo

–2つの絶対パス間の相対パスを求める
on calcRelativePathFromTwoAbsolutePaths(aPOSIXfile as string, bPOSIXfile as string)
  set aStr to NSString’s stringWithString:aPOSIXfile
  
set bStr to NSString’s stringWithString:bPOSIXfile
  
  
set aList to aStr’s pathComponents() as list
  
set bList to bStr’s pathComponents() as list
  
  
set aLen to length of aList
  
set bLen to length of bList
  
  
if aLen ≥ bLen then
    copy aLen to aMax
  else
    copy bLen to aMax
  end if
  
  
repeat with i from 1 to aMax
    set aTmp to contents of item i of aList
    
set bTmp to contents of item i of bList
    
    
if aTmp is not equal to bTmp then
      exit repeat
    end if
  end repeat
  
  
set bbList to items i thru -1 of bList
  
set aaItem to (length of aList) – i
  
  
set tmpStr to {}
  
repeat with ii from 1 to aaItem
    set the end of tmpStr to ".."
  end repeat
  
  
set allRes to NSString’s pathWithComponents:(tmpStr & bbList)
  
return allRes as text
end calcRelativePathFromTwoAbsolutePaths

★Click Here to Open This Script 

Posted in file File path Markdown Spotlight Text | Tagged 10.11savvy 10.12savvy 10.13savvy MacDown | Leave a comment

デスクトップ以下のスクリーンキャプチャファイルの一覧を取得 v2

Posted on 3月 26, 2018 by Takaaki Naganoya

指定フォルダ以下に存在するファイルのうち条件に合うものをSpotlightの機能を用いて抽出するAppleScriptです。デスクトップフォルダ以下にあるスクリーンキャプチャを検索します。

Spotlight検索にはShane Stanleyの「Metadata Lib」のバージョン2.0を使用しています。インストールしていない環境では動かないので、事前に~/Library/Script Libraries/フォルダにインストールしておいてください。

Metadata Libはv1.xではAppleScript用語辞書がついていませんでしたが、v2.xではAppleScript用語辞書(sdef)が追加され、いわゆる英単語っぽい表記でパラメータを指定できるようになりました。

再掲載にあたってv2.0の表記に書き換えてみました。

AppleScript名:デスクトップ以下のスクリーンキャプチャファイルの一覧を取得 v2
— Created 2017-09-23 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use mdLib : script "Metadata Lib" version "2.0.0"

set theFolder to path to desktop
set sStr to "kMDItemIsScreenCapture == %@"
set fRes to perform search in folders {theFolder} predicate string sStr search arguments {true}

return fRes

★Click Here to Open This Script 

Posted in Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Metadata Lib v2.0の命令をひととおりチェック

Posted on 3月 26, 2018 by Takaaki Naganoya
AppleScript名:Metadata Lib v2.0の命令をひととおりチェック
— Created 2017-09-23 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use mdLib : script "Metadata Lib" version "2.0.0" –https://www.macosxautomation.com/applescript/apps/

–mdfind
set theFolder to path to desktop
set sStr to "kMDItemResolutionHeightDPI == %@ && kMDItemResolutionWidthDPI == %@ && NOT (kMDItemContentTypeTree contains %@)"
set fRes to perform search in folders {theFolder} predicate string sStr search arguments {144, 144, "com.apple.icns"}
log fRes
–> {"/Users/me/Desktop/From Desktop 2018.1.9/FromDesktop/スクリーンショット 2015-12-18 13.02.14.png"}

–scope strings
set aRes to metadata scope strings
log aRes
–> {"kMDQueryScopeHome", "kMDQueryScopeNetwork", "kMDQueryScopeComputer", "kMDQueryScopeAllIndexed", "kMDQueryScopeComputerIndexed", "kMDQueryScopeNetworkIndexed"}
–https://developer.apple.com/documentation/coreservices/file_metadata/mdquery/query_search_scope_keys?preferredLanguage=occ

–mdls
set aFile to choose file with prompt ""
set aRes to fetch metadata for item aFile
log aRes
–> {kMDItemFSCreatorCode:0, kMDItemFSFinderFlags:0, kMDItemFSContentChangeDate:date "2018年3月14日水曜日 1:32:07", kMDItemFSName:"0261F5E3-9BE4-4007-B7D8-10E56E13FB24.dot", kMDItemDisplayName:"0261F5E3-9BE4-4007-B7D8-10E56E13FB24.dot", kMDItemFSInvisible:false, kMDItemFSSize:2506, kMDItemFSOwnerUserID:504, kMDItemDateAdded:date "2018年3月14日水曜日 1:32:07", kMDItemPhysicalSize:4096, kMDItemKind:"Microsoft Word 97 – 2004 テンプレート (.dot)", _kMDItemOwnerUserID:504, kMDItemContentTypeTree:{"public.item", "public.data", "com.microsoft.word.dot"}, kMDItemFSTypeCode:0, kMDItemFSIsExtensionHidden:false, kMDItemLogicalSize:2506, kMDItemFSLabel:0, kMDItemContentModificationDate:date "2018年3月14日水曜日 1:32:07", kMDItemUseCount:2, kMDItemContentType:"com.microsoft.word.dot", kMDItemFSOwnerGroupID:80, kMDItemContentCreationDate:date "2018年3月14日水曜日 1:32:07", kMDItemUsedDates:{date "2018年3月14日水曜日 0:00:00"}, kMDItemFSCreationDate:date "2018年3月14日水曜日 1:32:07"}

–既存のsavedsearchから情報を読み取る
set sFile to choose file of type {"com.apple.finder.smart-folder"} with prompt "Select saved search file (purple folder icon)" default location (path to home folder)
search strings from saved search (POSIX path of sFile)
–> {"((_kMDItemGroupId = 11) && (kMDItemContentCreationDate > 489942000))", "_kMDItemGroupId == \"11\" AND kMDItemContentCreationDate > \"489942000\""}

★Click Here to Open This Script 

Posted in Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

デスクトップ上のRetina解像度の画像でICNS以外のものを検索 v2

Posted on 3月 26, 2018 by Takaaki Naganoya

指定フォルダ以下に存在するファイルのうち条件に合うものをSpotlightの機能を用いて抽出するAppleScriptです。デスクトップフォルダ以下にあるRetina解像度の画像(144 x 144dpi)で、ファイル形式がICNS「以外のもの」を検索します。

Spotlight検索にはShane Stanleyの「Metadata Lib」のバージョン2.0を使用しています。インストールしていない環境では動かないので、事前に~/Library/Script Libraries/フォルダにインストールしておいてください。

Metadata Libはv1.xではAppleScript用語辞書がついていませんでしたが、v2.xではAppleScript用語辞書(sdef)が追加され、いわゆる英単語っぽい表記でパラメータを指定できるようになりました。

再掲載にあたってv2.0の表記に書き換えてみました。

AppleScript名:デスクトップ上のRetina解像度の画像でICNS以外のものを検索 v2
— Created 2017-09-23 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use mdLib : script "Metadata Lib" version "2.0.0" –https://www.macosxautomation.com/applescript/apps/

set theFolder to path to desktop
–v1.x
–set fRes to mdLib’s searchFolders:{theFolder} searchString:"kMDItemResolutionHeightDPI == %@ && kMDItemResolutionWidthDPI == %@ && NOT (kMDItemContentTypeTree contains %@)" searchArgs:{144, 144, "com.apple.icns"}
–> {"/Users/me/Desktop/FromDesktop/スクリーンショット 2015-12-18 13.02.14.png", "/Users/me/Desktop/FromDesktop/conicon.png", "/Users/me/Desktop/FromDesktop/スクリーンショット 2015-08-14 18.08.41.png"}

–v2.x
set sStr to "kMDItemResolutionHeightDPI == %@ && kMDItemResolutionWidthDPI == %@ && NOT (kMDItemContentTypeTree contains %@)"
set fRes to perform search in folders {theFolder} predicate string sStr search arguments {144, 144, "com.apple.icns"}
–> {"/Users/me/Desktop/From Desktop 2018.1.9/FromDesktop/スクリーンショット 2015-12-18 13.02.14.png"}

★Click Here to Open This Script 

Posted in Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定フォルダ以下のすべてのファイルのうち指定UTIに該当するものを取得(spotlightで処理)

Posted on 2月 15, 2018 by Takaaki Naganoya
AppleScript名:指定フォルダ以下のすべてのファイルを再帰で取得(spotlightで処理).scpt
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
use mdLib : script "Metadata Lib" version "1.0.0" –https://www.macosxautomation.com/applescript/apps/Script_Libs.html#Metadata_Lib

–set theFolder to choose folder
set theFolder to (path to desktop folder)
set theFiles to mdLib’s searchFolders:{theFolder} searchString:"kMDItemContentType IN[c] %@" searchArgs:{"com.apple.applescript.script", "com.apple.applescript.script-bundle"}

★Click Here to Open This Script 

Posted in file Spotlight System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定フォルダ以下のすべてのファイルを再帰で取得 v2

Posted on 2月 15, 2018 by Takaaki Naganoya

指定フォルダ以下のすべてのファイルを再帰で取得するAppleScriptです。

「指定フォルダ以下のファイルを取得する」やりかたは、Spotlightを使うのがベストです。ベストではあるものの、各ユーザーのHDDなりSSDは「破損している」ケースもあって、Spotligtの検索が効かない場合もあります。

また、マウントしたLAN上のファイルサーバーに対してSpotlightが効くかどうかは実際にやってみないと分かりません。OSが異なる可能性がありますし、同じmacOSであっても効くかどうかは実際に試してみるまではっきりしません(開発時に真っ先に確認するポイントでもあります。ファイルサーバーを相手に処理するつもりかどうかの確認です)。

そこで、地道に再帰処理でファイルを取得すること「も」試してみることになるわけですが、ここでFinderを使うと遅くなります。

OS X 10.6以降の64ビット化されたいわゆる「Cocoa Finder」は処理速度が低下しているため、大量のファイル処理をFinder経由で行うことは「悪手」といえます。数百個ぐらいでけっこうな処理速度の低下がみられます。1,000を超えると露骨に速度が下がります。フィルタ参照で条件をつけて抽出するのも速度低下につながります。さらに複数のフィルタ条件を指定するとアホみたいに遅くなります。Cocoa Finderの性能低下はハンパではありません。

たまに、Classic Mac OSの環境しか知らない人が久しぶりに現代の(64ビット化された)macOS上で昔と同じようにFinderに対して膨大なファイルの処理を行わせて「遅い」と文句を言っているのを見かけますが、Finder経由でのファイル処理が現実的ではないという状況を知らなければそういう感想になってしまうかもしれません。

# Classic MacOS〜macOS 10.6ぐらいまではFinder経由で行っても、極端に時間がかかることはありませんでした。それ以降の環境のお話です。また、macOS 10.7以降でも、数個〜数十程度のすくないファイルを処理する場合には、あまり問題になりません

そこで、NSFileManagerを用いてファイル処理を行うことで、「Spotlightほど速くはないものの、Finderで処理するよりははるかに高速」な処理を行えます。

AppleScript名:指定フォルダ以下のすべてのファイルを再帰で取得 v2
— Created 2017-08-04 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSString : a reference to current application’s NSString
property NSPredicate : a reference to current application’s NSPredicate
property NSFileManager : a reference to current application’s NSFileManager
property NSMutableArray : a reference to current application’s NSMutableArray

–set aFol to POSIX path of (choose folder)
set aFol to POSIX path of (path to desktop folder)

–set aList to retFullPathWithinAFolderWithRecursive(aFol) of me
set bList to retFullPathWithinAFolderWithRecursiveFilterByExt(aFol, "scpt") of me
–set cList to retFilenameWithinAFolderWithRecursiveFilterByExt(aFol, {"scpt", "scptd"}) of me
–set dList to retFullPathWithinAFolderWithRecursiveFilterByExtAndFileNameString(aFol, "png", "スクリーン") of me
–set eList to retFullPathWithinAFolderWithRecursiveFilterByExtAndFileNameString(aFol, {"scpt", "scptd"}, "並列") of me

–指定フォルダ以下のすべてのファイルを再帰で取得
on retFilenamesWithinAFolderWithRecursive(aFol)
  set anArray to NSMutableArray’s array()
  
set aPath to NSString’s stringWithString:aFol
  
set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath
  
  
repeat
    set aName to (dirEnum’s nextObject())
    
if aName = missing value then exit repeat
    
set aFullPath to aPath’s stringByAppendingPathComponent:aName
    
anArray’s addObject:(aFullPath’s lastPathComponent()’s stringByDeletingPathExtension() as string)
  end repeat
  
  
return anArray as list
end retFilenamesWithinAFolderWithRecursive

–指定フォルダ以下のすべてのファイルを再帰で取得
on retFullPathWithinAFolderWithRecursive(aFol)
  set anArray to NSMutableArray’s array()
  
set aPath to NSString’s stringWithString:aFol
  
set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath
  
  
repeat
    set aName to (dirEnum’s nextObject())
    
if aName = missing value then exit repeat
    
set aFullPath to aPath’s stringByAppendingPathComponent:aName
    
anArray’s addObject:(aFullPath’s lastPathComponent()’s stringByDeletingPathExtension() as string)
  end repeat
  
  
return anArray as list
end retFullPathWithinAFolderWithRecursive

–指定フォルダ以下のすべてのファイルを再帰で取得(拡張子で絞り込み)
on retFilenameWithinAFolderWithRecursiveFilterByExt(aFol, aExt)
  set anArray to NSMutableArray’s array()
  
set aPath to NSString’s stringWithString:aFol
  
set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath
  
  
repeat
    set aName to (dirEnum’s nextObject())
    
if aName = missing value then exit repeat
    
set aFullPath to aPath’s stringByAppendingPathComponent:aName
    
anArray’s addObject:aFullPath
  end repeat
  
  
set thePred to NSPredicate’s predicateWithFormat:"pathExtension == [c]%@" argumentArray:{aExt}
  
set bArray to anArray’s filteredArrayUsingPredicate:thePred
  
  
return bArray as list
end retFilenameWithinAFolderWithRecursiveFilterByExt

–指定フォルダ以下のすべてのファイルを再帰で取得(拡張子で絞り込み)
on retFullPathWithinAFolderWithRecursiveFilterByExt(aFol, aExt)
  set anArray to NSMutableArray’s array()
  
set aPath to NSString’s stringWithString:aFol
  
set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath
  
  
repeat
    set aName to (dirEnum’s nextObject())
    
if aName = missing value then exit repeat
    
set aFullPath to aPath’s stringByAppendingPathComponent:aName
    
anArray’s addObject:aFullPath
  end repeat
  
  
set thePred to NSPredicate’s predicateWithFormat:"pathExtension == [c]%@" argumentArray:{aExt}
  
set bArray to anArray’s filteredArrayUsingPredicate:thePred
  
  
return bArray as list
end retFullPathWithinAFolderWithRecursiveFilterByExt

–指定フォルダ以下のすべてのファイルを再帰で取得(拡張子リストで絞り込み)
on retFullPathWithinAFolderWithRecursiveFilterByExtList(aFol, aExtList)
  set anArray to NSMutableArray’s array()
  
set aPath to NSString’s stringWithString:aFol
  
set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath
  
  
repeat
    set aName to (dirEnum’s nextObject())
    
if aName = missing value then exit repeat
    
set aFullPath to aPath’s stringByAppendingPathComponent:aName
    
anArray’s addObject:aFullPath
  end repeat
  
  
set thePred to NSPredicate’s predicateWithFormat:"pathExtension IN [c]%@" argumentArray:{aExtList}
  
set bArray to anArray’s filteredArrayUsingPredicate:thePred
  
  
return bArray as list
end retFullPathWithinAFolderWithRecursiveFilterByExtList

–指定フォルダ以下のすべてのファイルを再帰で取得(文字列と拡張子で絞り込み)
on retFullPathWithinAFolderWithRecursiveFilterByExtListAndFileNameString(aFol, aExt, aNameString)
  set anArray to NSMutableArray’s array()
  
set aPath to NSString’s stringWithString:aFol
  
set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath
  
  
repeat
    set aName to (dirEnum’s nextObject())
    
if aName = missing value then exit repeat
    
set aFullPath to aPath’s stringByAppendingPathComponent:aName
    
anArray’s addObject:aFullPath
  end repeat
  
  
set thePred to NSPredicate’s predicateWithFormat:"pathExtension == [c]%@ && lastPathComponent CONTAINS %@" argumentArray:{aExt, aNameString}
  
set bArray to anArray’s filteredArrayUsingPredicate:thePred
  
  
return bArray as list
end retFullPathWithinAFolderWithRecursiveFilterByExtListAndFileNameString

–指定フォルダ以下のすべてのファイルを再帰で取得(文字列と拡張子リストで絞り込み)
on retFullPathWithinAFolderWithRecursiveFilterByExtAndFileNameString(aFol, aExtList, aNameString)
  set anArray to NSMutableArray’s array()
  
set aPath to NSString’s stringWithString:aFol
  
set dirEnum to NSFileManager’s defaultManager()’s enumeratorAtPath:aPath
  
  
repeat
    set aName to (dirEnum’s nextObject())
    
if aName = missing value then exit repeat
    
set aFullPath to aPath’s stringByAppendingPathComponent:aName
    
anArray’s addObject:aFullPath
  end repeat
  
  
set thePred to NSPredicate’s predicateWithFormat:"pathExtension IN [c]%@ && lastPathComponent CONTAINS %@" argumentArray:{aExtList, aNameString}
  
set bArray to anArray’s filteredArrayUsingPredicate:thePred
  
  
return bArray as list
end retFullPathWithinAFolderWithRecursiveFilterByExtAndFileNameString

★Click Here to Open This Script 

Posted in file Spotlight System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定フォルダ以下のテキストファイルのファイル名冒頭についている数字から欠番を求める

Posted on 2月 13, 2018 by Takaaki Naganoya
AppleScript名:指定フォルダ以下のテキストファイルのファイル名冒頭についている数字から欠番を求める
— Created 2017-09-04 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
use mdLib : script "Metadata Lib" version "1.0.0" –https://www.macosxautomation.com/applescript/apps/Script_Libs.html#Metadata_Lib
use bPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

property NSString : a reference to current application’s NSString
property SMSForder : a reference to current application’s SMSForder
property NSIndexSet : a reference to current application’s NSIndexSet
property NSMutableSet : a reference to current application’s NSMutableSet
property NSMutableArray : a reference to current application’s NSMutableArray
property NSRegularExpression : a reference to current application’s NSRegularExpression
property NSRegularExpressionAnchorsMatchLines : a reference to current application’s NSRegularExpressionAnchorsMatchLines
property NSRegularExpressionDotMatchesLineSeparators : a reference to current application’s NSRegularExpressionDotMatchesLineSeparators

load framework –BridgePlus’s force framework loading command

–選択したフォルダ以下のPlain TextをすべてSpotlightで求める(POSIX path list)
set theFolder to (choose folder)

set a1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
set aRes to retMissingNumberFromEachFiles(theFolder, {"public.plain-text"}) of me
–>  {}
set b1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate()
set c1Dat to b1Dat – a1Dat

on retMissingNumberFromEachFiles(theFolder, fileTypeList)
  set theFiles to mdLib’s searchFolders:{theFolder} searchString:"kMDItemContentType IN[c] %@" searchArgs:fileTypeList
  
if theFiles = {} then return
  
  
–取得したPOSIX Pathのリストからファイル名の部分のみ抽出
  
set anArray to NSMutableArray’s arrayWithArray:theFiles
  
set bArray to (anArray’s valueForKeyPath:"lastPathComponent") as list
  
  
–各ファイルの名称の冒頭から1~3桁 の数字を取り出して、全角–>半角変換を行いつつリストに追加
  
set nArray to NSMutableArray’s new()
  
repeat with i in bArray
    set j to contents of i
    
set aRes to (my findPattern:"^\\d{1,3}" inString:j)
    
if aRes is not equal to {} then
      set jj to (contents of first item of aRes) as string
      
set jj2 to (SMSForder’s transformedFrom:jj ICUTransform:"Fullwidth-Halfwidth" inverse:false) as integer
      (
nArray’s addObject:jj2)
    end if
  end repeat
  
  
–最大値、最小値をもとに連番リストを作成し、ファイル名から得られた配列データとの補集合を求める
  
set maxRes to (nArray’s valueForKeyPath:"@max.self")’s intValue()
  
set minRes to (nArray’s valueForKeyPath:"@min.self")’s intValue()
  
  
–最小値から最大値までの連番リスト作成
  
set theIndexSet to NSIndexSet’s indexSetWithIndexesInRange:{minRes, maxRes}
  
set theList to (SMSForder’s arrayWithIndexSet:theIndexSet) as list
  
  
set aSet to NSMutableSet’s setWithArray:theList
  
set bSet to NSMutableSet’s setWithArray:nArray
  
aSet’s minusSet:bSet –補集合
  
  
return (aSet’s allObjects() as list)
  
end retMissingNumberFromEachFiles

on findPattern:thePattern inString:theString
  set theOptions to ((NSRegularExpressionDotMatchesLineSeparators) as integer) + ((NSRegularExpressionAnchorsMatchLines) as integer)
  
set theRegEx to NSRegularExpression’s regularExpressionWithPattern:thePattern options:theOptions |error|:(missing value)
  
set theFinds to theRegEx’s matchesInString:theString options:0 range:{location:0, |length|:length of theString}
  
set theFinds to theFinds as list
  
set theResult to {}
  
set theNSString to NSString’s stringWithString:theString
  
  
repeat with i in theFinds
    set theRange to (contents of i)’s range()
    
set end of theResult to (theNSString’s substringWithRange:theRange) as string
  end repeat
  
return theResult
end findPattern:inString:

★Click Here to Open This Script 

Posted in file Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定フォルダ内のラベル(Yellow, Red, Orange)のファイル一覧を取得

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:指定フォルダ内のラベル(Yellow, Red, Orange)のファイル一覧を取得
— Created 2017-12-05 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use mdLib : script "Metadata Lib" version "1.0.0" –https://www.macosxautomation.com/applescript/apps/Script_Libs.html#Metadata_Lib

set aLabelList to {5, 6, 7} –Yellow, Red, Orange
–0: No Label, 1: Gray, 2: Green, 3: Purple, 4: Blue, 5: Yellow, 6: Red, 7: Orange
set thePath to POSIX path of (path to desktop)
set aRes to spotlightFindByLabels(aLabelList, thePath) of me
–> list of POSIX path

on spotlightFindByLabels(aLabelList as list, thePath as string)
  set aList to makeRepeatinglList(length of aLabelList, "kMDItemFSLabel == %@")
  
set aStr to retStrFromArrayWithDelimiter(aList, " OR ") of me
  
set fRes to mdLib’s searchFolders:{thePath} searchString:aStr searchArgs:aLabelList
  
return fRes
end spotlightFindByLabels

–リストを指定デリミタをはさんでテキスト化
on retStrFromArrayWithDelimiter(aList as list, aDelim as string)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
return (anArray’s componentsJoinedByString:aDelim) as string
end retStrFromArrayWithDelimiter

–指定回数、指定アイテムを連結したリストを作成
on makeRepeatinglList(hitNum as integer, hitItem as string)
  set outList to {}
  
repeat hitNum times
    set the end of outList to hitItem
  end repeat
  
return outList
end makeRepeatinglList

★Click Here to Open This Script 

Posted in file Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

表示中のCotEditor書類と同じフォルダでラベルがついているものから選択して表示

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:表示中のCotEditor書類と同じフォルダでラベルがついているものから選択して表示
— Created 2017-12-15 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use bPlus : script "BridgePlus"
use mdLib : script "Metadata Lib" version "1.0.0"

property NSURLIsDirectoryKey : a reference to current application’s NSURLIsDirectoryKey
property NSDirectoryEnumerationSkipsHiddenFiles : a reference to current application’s NSDirectoryEnumerationSkipsHiddenFiles
property NSPredicate : a reference to current application’s NSPredicate
property NSMutableArray : a reference to current application’s NSMutableArray
property NSDirectoryEnumerationSkipsPackageDescendants : a reference to current application’s NSDirectoryEnumerationSkipsPackageDescendants
property NSFileManager : a reference to current application’s NSFileManager
property |NSURL| : a reference to current application’s |NSURL|
property NSDirectoryEnumerationSkipsSubdirectoryDescendants : a reference to current application’s NSDirectoryEnumerationSkipsSubdirectoryDescendants
property NSArray : a reference to current application’s NSArray
property NSSortDescriptor : a reference to current application’s NSSortDescriptor
property SMSForder : a reference to current application’s SMSForder

load framework

tell application "CotEditor"
  set dCount to count every document
  
if dCount = 0 then return
  
  
tell front document
    set curPath to path
  end tell
  
  
tell window 1
    set aBounds to bounds
  end tell
end tell

set aPath to current application’s NSString’s stringWithString:curPath
set fileName to (aPath’s lastPathComponent()) –ファイル名
set pathExtension to aPath’s pathExtension() as string
set parentFol to (aPath’s stringByDeletingLastPathComponent()) as string —親フォルダ

–同じフォルダから同じ拡張子のファイルのファイル名を取得
–set fList to my getFilesByIncludedStringInName:(pathExtension) fromDirectory:(parentFol) exceptPackages:(true)
set fList to spotlightFindByLabels({1, 2, 3, 4, 5, 6, 7}, parentFol) of me

–昇順ソート
set aArray to NSArray’s arrayWithArray:fList
set desc1 to NSSortDescriptor’s sortDescriptorWithKey:"self" ascending:true selector:"localizedCaseInsensitiveCompare:"
set bArray to aArray’s sortedArrayUsingDescriptors:{desc1}
set cList to bArray as list

set selRes to choose from list cList
if selRes = false then return –Cancel

set newPath to contents of first item of selRes

tell application "CotEditor"
  set oldDoc to front document
  
  
open (POSIX file newPath) as alias
  
tell window 1
    set bounds to aBounds
  end tell
  
  
close oldDoc without saving
end tell

makeWinVertical() of me –縦書き表示

–Make CotEditor’s front window to Vertical display mode (Tategaki)
on makeWinVertical()
  activate application "CotEditor"
  
tell application "System Events"
    tell process "CotEditor"
      try
        click menu item "縦書きで表示" of menu 1 of menu bar item "フォーマット" of menu bar 1
      end try
    end tell
  end tell
end makeWinVertical

on retFileFormatUTI(aExt as string)
  if aExt begins with "." then set aExt to text 2 thru -1 of aExt
  
return (current application’s SMSForder’s UTIForExtension:aExt)
end retFileFormatUTI

on spotlightFindByLabels(aLabelList as list, thePath as string)
  set aList to makeRepeatinglList(length of aLabelList, "kMDItemFSLabel == %@")
  
set aStr to retStrFromArrayWithDelimiter(aList, " OR ") of me
  
set fRes to mdLib’s searchFolders:{thePath} searchString:aStr searchArgs:aLabelList
  
return fRes
end spotlightFindByLabels

–リストを指定デリミタをはさんでテキスト化
on retStrFromArrayWithDelimiter(aList as list, aDelim as string)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
return (anArray’s componentsJoinedByString:aDelim) as string
end retStrFromArrayWithDelimiter

–指定回数、指定アイテムを連結したリストを作成
on makeRepeatinglList(hitNum as integer, hitItem as string)
  set outList to {}
  
repeat hitNum times
    set the end of outList to hitItem
  end repeat
  
return outList
end makeRepeatinglList

★Click Here to Open This Script 

Posted in file Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy CotEditor | Leave a comment

表示中のCotEditor書類と同じフォルダで各書類の1行目で選択して表示

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:表示中のCotEditor書類と同じフォルダで各書類の1行目で選択して表示
— Created 2017-12-15 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use bPlus : script "BridgePlus"
use mdLib : script "Metadata Lib" version "1.0.0"
use jLib : script "japaneseTextEncodingDetector"

property NSURLIsDirectoryKey : a reference to current application’s NSURLIsDirectoryKey
property NSDirectoryEnumerationSkipsHiddenFiles : a reference to current application’s NSDirectoryEnumerationSkipsHiddenFiles
property NSPredicate : a reference to current application’s NSPredicate
property NSMutableArray : a reference to current application’s NSMutableArray
property NSDirectoryEnumerationSkipsPackageDescendants : a reference to current application’s NSDirectoryEnumerationSkipsPackageDescendants
property NSFileManager : a reference to current application’s NSFileManager
property |NSURL| : a reference to current application’s |NSURL|
property NSDirectoryEnumerationSkipsSubdirectoryDescendants : a reference to current application’s NSDirectoryEnumerationSkipsSubdirectoryDescendants
property NSArray : a reference to current application’s NSArray
property NSSortDescriptor : a reference to current application’s NSSortDescriptor
property SMSForder : a reference to current application’s SMSForder

load framework

tell application "CotEditor"
  set dCount to count every document
  
if dCount = 0 then return
  
  
tell front document
    set curPath to path
  end tell
  
  
tell window 1
    set aBounds to bounds
  end tell
end tell

set aPath to current application’s NSString’s stringWithString:curPath
set fileName to (aPath’s lastPathComponent()) –ファイル名
set pathExtension to aPath’s pathExtension() as string
set parentFol to (aPath’s stringByDeletingLastPathComponent()) as string —親フォルダ

–同じフォルダから同じ拡張子のファイルのファイル名を取得
set fList to my getFilesByIncludedStringInName:(pathExtension) fromDirectory:(parentFol) exceptPackages:(true)

–昇順ソート
set aArray to NSArray’s arrayWithArray:fList
set desc1 to NSSortDescriptor’s sortDescriptorWithKey:"self" ascending:true selector:"localizedCaseInsensitiveCompare:"
set bArray to aArray’s sortedArrayUsingDescriptors:{desc1}
set cList to bArray as list

–ダイアログ表示用のデータを作成
set ccList to {}
repeat with i in cList
  set j to POSIX path of (i as string)
  
set aStr to readJapanesTextFileWithGuessingEncoding(j) of jLib
  
if aStr = missing value or aStr = false then
    display dialog "Encoding Error"
    
return
  end if
  
  
set aPath to (current application’s NSString’s stringWithString:j)
  
set fileName to (aPath’s lastPathComponent()) as string –ファイル名  
  
set aFirst to first item of paragraphs of aStr
  
set the end of ccList to (fileName & " / " & aFirst)
end repeat

set aMes to "項目を選択してください"
set selRes to retItemFromListByItemNo(ccList, aMes) of me
if selRes = false then return –Cancel

set newPath to contents of item selRes of cList

tell application "CotEditor"
  set oldDoc to front document
  
  
open (POSIX file newPath) as alias
  
tell window 1
    set bounds to aBounds
  end tell
  
  
close oldDoc without saving
end tell

makeWinVertical() of me –縦書き表示

–Make CotEditor’s front window to Vertical display mode (Tategaki)
on makeWinVertical()
  activate application "CotEditor"
  
tell application "System Events"
    tell process "CotEditor"
      try
        click menu item "縦書きで表示" of menu 1 of menu bar item "フォーマット" of menu bar 1
      end try
    end tell
  end tell
end makeWinVertical

on retFileFormatUTI(aExt as string)
  if aExt begins with "." then set aExt to text 2 thru -1 of aExt
  
return (current application’s SMSForder’s UTIForExtension:aExt)
end retFileFormatUTI

on spotlightFindByLabels(aLabelList as list, thePath as string)
  set aList to makeRepeatinglList(length of aLabelList, "kMDItemFSLabel == %@")
  
set aStr to retStrFromArrayWithDelimiter(aList, " OR ") of me
  
set fRes to mdLib’s searchFolders:{thePath} searchString:aStr searchArgs:aLabelList
  
return fRes
end spotlightFindByLabels

–リストを指定デリミタをはさんでテキスト化
on retStrFromArrayWithDelimiter(aList as list, aDelim as string)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
return (anArray’s componentsJoinedByString:aDelim) as string
end retStrFromArrayWithDelimiter

–指定回数、指定アイテムを連結したリストを作成
on makeRepeatinglList(hitNum as integer, hitItem as string)
  set outList to {}
  
repeat hitNum times
    set the end of outList to hitItem
  end repeat
  
return outList
end makeRepeatinglList

–指定フォルダ内の指定文字列を含むファイル名のファイルをPOSIX pathのlistで抽出する
on getFileNamesByIncludedStringInName:(fileNameStr as string) fromDirectory:(sourceFolder) exceptPackages:(packageF as boolean)
  set fileManager to NSFileManager’s defaultManager()
  
set aURL to |NSURL|’s fileURLWithPath:sourceFolder
  
set theOptions to ((NSDirectoryEnumerationSkipsPackageDescendants) as integer) + ((NSDirectoryEnumerationSkipsHiddenFiles) as integer) + ((NSDirectoryEnumerationSkipsSubdirectoryDescendants) as integer)
  
set directoryContents to fileManager’s contentsOfDirectoryAtURL:aURL includingPropertiesForKeys:{} options:theOptions |error|:(missing value)
  
set findPredicates to NSPredicate’s predicateWithFormat_("lastPathComponent CONTAINS %@", fileNameStr)
  
set foundItemList to directoryContents’s filteredArrayUsingPredicate:findPredicates
  
  
–Remove Folders From found URL Array
  
set anArray to NSMutableArray’s alloc()’s init()
  
repeat with i in foundItemList
    set j to contents of i
    
set {theResult, isDirectory} to (j’s getResourceValue:(reference) forKey:(NSURLIsDirectoryKey) |error|:(missing value))
    
    
–Collect files
    
if (isDirectory as boolean = false) then
      (anArray’s addObject:j)
      
    else if (packageF = false) then
      –Allow Package files?
      
set {theResult, isPackage} to (j’s getResourceValue:(reference) forKey:(current application’s NSURLIsPackageKey) |error|:(missing value))
      
if (isPackage as boolean) = true then
        (anArray’s addObject:j)
      end if
    end if
    
  end repeat
  
  
return (anArray’s valueForKey:"lastPathComponent") as list
end getFileNamesByIncludedStringInName:fromDirectory:exceptPackages:

–指定フォルダ内の指定文字列を含むファイル名のファイルをPOSIX pathのlistで抽出する
on getFilesByIncludedStringInName:(fileNameStr as string) fromDirectory:(sourceFolder) exceptPackages:(packageF as boolean)
  set fileManager to NSFileManager’s defaultManager()
  
set aURL to |NSURL|’s fileURLWithPath:sourceFolder
  
set theOptions to ((NSDirectoryEnumerationSkipsPackageDescendants) as integer) + ((NSDirectoryEnumerationSkipsHiddenFiles) as integer) + ((NSDirectoryEnumerationSkipsSubdirectoryDescendants) as integer)
  
set directoryContents to fileManager’s contentsOfDirectoryAtURL:aURL includingPropertiesForKeys:{} options:theOptions |error|:(missing value)
  
set findPredicates to NSPredicate’s predicateWithFormat_("lastPathComponent CONTAINS %@", fileNameStr)
  
set foundItemList to directoryContents’s filteredArrayUsingPredicate:findPredicates
  
  
–Remove Folders From found URL Array
  
set anArray to NSMutableArray’s alloc()’s init()
  
repeat with i in foundItemList
    set j to contents of i
    
set {theResult, isDirectory} to (j’s getResourceValue:(reference) forKey:(NSURLIsDirectoryKey) |error|:(missing value))
    
    
–Collect files
    
if (isDirectory as boolean = false) then
      (anArray’s addObject:j)
      
    else if (packageF = false) then
      –Allow Package files?
      
set {theResult, isPackage} to (j’s getResourceValue:(reference) forKey:(current application’s NSURLIsPackageKey) |error|:(missing value))
      
if (isPackage as boolean) = true then
        (anArray’s addObject:j)
      end if
    end if
    
  end repeat
  
  
return (anArray’s valueForKey:"path") as list
end getFilesByIncludedStringInName:fromDirectory:exceptPackages:

–リストから選択してアイテム番号を返す
on retItemFromListByItemNo(aList, aMes)
  set aRes to choose from list aList with prompt aMes
  
if aRes = false then return 0
  
  
set aRes to contents of item 1 of aRes
  
set hitNum to 1
  
repeat with i in aList
    set j to contents of i
    
if j is equal to aRes then
      exit repeat
    end if
    
set hitNum to hitNum + 1
  end repeat
  
return hitNum
end retItemFromListByItemNo

★Click Here to Open This Script 

Posted in GUI Scripting Spotlight | Tagged 10.11savvy 10.12savvy 10.13savvy CotEditor | Leave a comment

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • macOS 13, Ventura(継続更新)
  • アラートダイアログ上にWebViewで3Dコンテンツを表示(WebGL+three.js)v3
  • UI Browserがgithub上でソース公開され、オープンソースに
  • macOS 13 TTS Voice環境に変更
  • Xcode 14.2でAppleScript App Templateを復活させる
  • 2022年に書いた価値あるAppleScript
  • ChatGPTで文章のベクトル化(Embedding)
  • 新発売:AppleScriptからSiriを呼び出そう!
  • iWork 12.2がリリースされた
  • 従来と異なるmacOS 13の性格?
  • 新発売:CotEditor Scripting Book with AppleScript
  • macOS 13対応アップデート:AppleScript実践的テクニック集(1)GUI Scripting
  • AS関連データの取り扱いを容易にする(はずの)privateDataTypeLib
  • macOS 13でNSNotFoundバグふたたび
  • macOS 12.5.1、11.6.8でFinderのselectionでスクリーンショット画像をopenできない問題
  • ChatGPTでchatに対する応答文を取得
  • 新発売:iWork Scripting Book with AppleScript
  • Finderの隠し命令openVirtualLocationが発見される
  • macOS 13.1アップデートでスクリプトエディタの挙動がようやくまともに
  • あのコン過去ログビューワー(暫定版)

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1390) 10.14savvy (586) 10.15savvy (434) 11.0savvy (277) 12.0savvy (185) 13.0savvy (55) CotEditor (60) Finder (47) iTunes (19) Keynote (98) NSAlert (60) NSArray (51) NSBezierPath (18) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (51) NSDictionary (27) NSFileManager (23) NSFont (18) NSImage (41) NSJSONSerialization (21) NSMutableArray (62) NSMutableDictionary (21) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (117) NSURL (97) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (56) Pages (37) Safari (41) Script Editor (20) WKUserContentController (21) WKUserScript (20) WKUserScriptInjectionTimeAtDocumentEnd (18) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • Clipboard
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • drive
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC