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

カテゴリー: list

2つの1D Listから重複項目のみ抽出。個別の重複項目のチェックつき

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2つの1D Listから重複項目のみ抽出。個別の重複項目のチェックつき
— Created 2017-12-17 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property NSCountedSet : a reference to current application’s NSCountedSet

set aList to {1, 2, 3, 4, 5}
set bList to {0, 1, 2, 4, 5, 6}

–それぞれのListに重複項目が存在するかをチェック
set aRes1 to returnDuplicatesOnly(aList) of me
set bRes1 to returnDuplicatesOnly(bList) of me
if {aRes1, bRes1} is not equal to {{}, {}} then return false

–aListとbListを連結したListで重複が存在するかをチェック
set aArray to current application’s NSArray’s arrayWithArray:aList
set bArray to current application’s NSArray’s arrayWithArray:bList
set cArray to aArray’s arrayByAddingObjectsFromArray:bArray

set cRes to returnDuplicatesOnly(cArray) of me
–>  {​​​​​5, ​​​​​1, ​​​​​2, ​​​​​4​​​}

on returnDuplicatesOnly(aList as list)
  set aSet to NSCountedSet’s alloc()’s initWithArray:aList
  
set bList to (aSet’s allObjects()) as list
  
  
set dupList to {}
  
repeat with i in bList
    set aRes to (aSet’s countForObject:i)
    
if aRes > 1 then
      set the end of dupList to (contents of i)
    end if
  end repeat
  
  
return dupList
end returnDuplicatesOnly

★Click Here to Open This Script 

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

ASOCでSystemのアラートサウンド名称を取得して同時に鳴らす v2.2a(Array内のオブジェクトに一括指令)

Posted on 2月 7, 2018 by Takaaki Naganoya

使用中のコンピュータにインストールされているアラートサウンド(警告音)の名称を取得して、音を同時に鳴らすAppleScriptです。

NSArrayに入れたオブジェクトに対して一括でメッセージを送るという処理の実験でもあります。

AppleScript名:ASOCでSystemのアラートサウンド名称を取得して同時に鳴らす v2.2a(Array内のオブジェクトに一括指令)
— Created 2015-11-06 by Takaaki Naganoya
— Modified 2015-11-07 by Shane Stanley–Recovery the compatibility for OS X 10.10.x
— Modified 2015-11-07 by Takaaki Naganoya–NSArrayからvalueForKeyで加工しつつ一気にArrayで値を返す内容を検証
— Modified 2015-11-07 by Shane Stanley–Cooler processing
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

set nList to getSystemAlertSoundNames() of me
–>  {​​​​​"Basso", ​​​​​"Blow", ​​​​​"Bottle", ​​​​​"Frog", ​​​​​"Funk", ​​​​​"Glass", ​​​​​"Hero", ​​​​​"Morse", ​​​​​"Ping", ​​​​​"Pop", ​​​​​"Purr", ​​​​​"Sosumi", ​​​​​"Submarine", ​​​​​"Tink"​​​}

set aArray to current application’s NSMutableArray’s new()

repeat with i in nList
  (aArray’s addObject:(current application’s NSSound’s soundNamed:i))
end repeat

aArray’s makeObjectsPerformSelector:"play" withObject:0 –同時に鳴らす

–Get System Alert FileName List
on getSystemAlertSoundNames()
  set aExt to "aiff" — no dot
  
set aFol to "/System/Library/Sounds"
  
set fList to getFileNameListFromPOSIXpath(aFol, aExt) of me
  
return fList
end getSystemAlertSoundNames

–Get File Name List from POSIX path and file Extensions
on getFileNameListFromPOSIXpath(aFol, aExt)
  set aFM to current application’s NSFileManager’s defaultManager()
  
set aURL to current application’s |NSURL|’s fileURLWithPath:aFol
  
set urlArray to aFM’s contentsOfDirectoryAtURL:aURL includingPropertiesForKeys:{} options:(current application’s NSDirectoryEnumerationSkipsHiddenFiles) |error|:(missing value)
  
set thePred to current application’s NSPredicate’s predicateWithFormat:"pathExtension == [c]%@" argumentArray:{aExt}
  
set anArray to urlArray’s filteredArrayUsingPredicate:thePred
  
set bArray to (anArray’s valueForKeyPath:"lastPathComponent.stringByDeletingPathExtension") –Cool !!
  
return bArray as list
end getFileNameListFromPOSIXpath

★Click Here to Open This Script 

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

1Dリスト内の数値をすべて文字列化

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1Dリスト内の数値をすべて文字列化
— Created 2017-01-30 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set anArray to current application’s NSArray’s arrayWithArray:{1, 2, 3}
set aVal to anArray’s valueForKey:"stringValue"
–>  (NSArray) {"1", "2", "3"}

★Click Here to Open This Script 

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

1Dリスト内のテキストの文字列長を取得

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1Dリスト内のテキストの文字列長を取得
— Created 2017-01-30 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set anArray to current application’s NSArray’s arrayWithArray:{"aaaa1", "sss2", "aaaa3"}
set aVal to anArray’s valueForKeyPath:"length"
–>  (NSArray) {​​​​​5, ​​​​​4, ​​​​​5​​​}

★Click Here to Open This Script 

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

1Dリスト内の数値をすべて浮動小数点表現に

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1Dリスト内の数値をすべて浮動小数点表現に
— Created 2017-01-30 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set anArray to current application’s NSArray’s arrayWithArray:{1, 2, 3}
set aVal to anArray’s valueForKey:"doubleValue"
–>  (NSArray) {​​​​​1.0, ​​​​​2.0, ​​​​​3.0​​​}

★Click Here to Open This Script 

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

1Dリスト内の数値をすべて整数に

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1Dリスト内の数値をすべて整数に
— Created 2017-01-30 16:01:49 +0900 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set anArray to current application’s NSArray’s arrayWithArray:{1.0, 0.0, 1.0, -1.0}
set aVal to anArray’s valueForKey:"intValue"
–>  (NSArray) {​​​​​1, ​​​​​0, ​​​​​1, ​​​​​-1​​​}

★Click Here to Open This Script 

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

2Dリスト内の要素をすべて加算

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2Dリスト内の要素をすべて加算
— Created 2017-10-01 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aList to {{1, 2, 3, 4, 5, 6, 4}, {1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 16, 0, 0}}
set aRes to getTotalValueFrom2DArray(aList) of me
–>  77 –total value is 0

on getTotalValueFrom2DArray(aList)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
set eRes to (anArray’s valueForKeyPath:"@unionOfArrays.self")’s valueForKeyPath:"@sum.self"
  
return eRes as integer
end getTotalValueFrom2DArray

★Click Here to Open This Script 

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

2Dリスト内の要素の平均値を求める

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2Dリスト内の要素の平均値を求める
— Created 2017-10-01 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aList to {{1, 2, 3, 4, 5, 6, 4}, {1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 16, 0, 0}} –7,6, 8 items
set aRes to getAverageValueFrom2DArray(aList) of me
–>  4 –average value is 0

on getAverageValueFrom2DArray(aList)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
set eRes to (anArray’s valueForKeyPath:"@unionOfArrays.self")’s valueForKeyPath:"@avg.self"
  
return eRes as integer
end getAverageValueFrom2DArray

★Click Here to Open This Script 

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

2Dリスト内の要素のすべての要素をカウント

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2Dリスト内の要素のすべての要素をカウント
— Created 2017-10-01 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

–set aList to {{1, 2, 3, 4, 5, 6, 4}, {1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 16, 0, 0}}
set aList to {{{1, 2}, {3, 4}, {5, 6, 4}}, {{1, 2}, {3, 4, 5, 6}, {{1, 2}, {3, 4, 5}, {16, 0, 0}}}}
set aRes to countEveryItemOf2DArray(aList) of me
–>  21

on countEveryItemOf2DArray(aList)
  set bList to FlattenList(aList) of me
  
return (length of bList)
end countEveryItemOf2DArray

–By Paul Berkowitz
–2009年1月27日 2:24:08:JST
–Re: Flattening Nested Lists
on FlattenList(aList)
  set oldDelims to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to {"????"}
  
set aString to aList as text
  
set aList to text items of aString
  
set AppleScript’s text item delimiters to oldDelims
  
return aList
end FlattenList

★Click Here to Open This Script 

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

2Dリスト内の要素のうち最大値を求める

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2Dリスト内の要素のうち最大値を求める
— Created 2017-10-01 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aList to {{1, 2, 3, 4, 5, 6, 4}, {1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 16, 0, 0}} –7,6, 8 items
set aRes to getMaxValueFrom2DArray(aList) of me
–>  16 –max value is 16

on getMaxValueFrom2DArray(aList)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
set eRes to (anArray’s valueForKeyPath:"@unionOfArrays.self")’s valueForKeyPath:"@max.self"
  
return eRes as integer
end getMaxValueFrom2DArray

★Click Here to Open This Script 

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

2Dリスト内の要素のうち最小値を求める

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2Dリスト内の要素のうち最小値を求める
— Created 2017-10-01 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aList to {{1, 2, 3, 4, 5, 6, 4}, {1, 2, 3, 4, 5, 6}, {1, 2, 3, 4, 5, 16, 0, 0}} –7,6, 8 items
set aRes to getMinValueFrom2DArray(aList) of me
–>  0 –min value is 0

on getMinValueFrom2DArray(aList)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
set eRes to (anArray’s valueForKeyPath:"@unionOfArrays.self")’s valueForKeyPath:"@min.self"
  
return eRes as integer
end getMinValueFrom2DArray

★Click Here to Open This Script 

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

ASOCでテキストとリストの変換

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:ASOCでテキストとリストの変換
— Created 2015-10-14 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aList to {"あああああ", "いいいいいいいい", "ううううううううううう", "えええええええええええ", "おおおおおおおおおお"}
set aRes to my retStrFromArrayWithDelimiter(aList, return)
(*
"あああああ
いいいいいいいい
ううううううううううう
えええええええええええ
おおおおおおおおおお"
*)

set bList to my parseByDelim(aRes, return)
–>  {​​​​​"あああああ", ​​​​​"いいいいいいいい", ​​​​​"ううううううううううう", ​​​​​"えええええええええええ", ​​​​​"おおおおおおおおおお"​​​}

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

on retArrowText(aList, aDelim) –自分のASでよく使うハンドラ名称なので、同じものを用意
  return my retStrFromArrayWithDelimiter(aList, aDelim)
end retArrowText

–テキストを指定デリミタでリスト化
on parseByDelim(aData, aDelim)
  set aText to current application’s NSString’s stringWithString:aData
  
set aList to aText’s componentsSeparatedByString:aDelim
  
return aList as list
end parseByDelim

★Click Here to Open This Script 

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

1Dリストを指定個数ごとにリスト化して2D化 v3.2

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1Dリストを指定個数ごとにリスト化して2D化 v3.2
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use bPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

script spd
  property aList : {}
end script

–テストデータ作成
set aList of spd to {}
repeat 100000 times
  set the end of aList of spd to (random number from 10000 to 9999)
end repeat

set a1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate() –時間計測

set aGroupNum to 100000
set b to (current application’s SMSForder’s subarraysFrom:(aList of spd) groupedBy:aGroupNum |error|:(missing value)) as list

set b1Dat to current application’s NSDate’s timeIntervalSinceReferenceDate() –時間計測
set c1Dat to b1Dat – a1Dat
–> 0.688337981701

★Click Here to Open This Script 

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

2Dリストから、指定カラムのデータを削除する v3

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2Dリストから、指定カラムのデータを削除する v3
— Created 2017-11-25 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
–http://piyocast.com/as/archives/5000

set aList to {{1, 2, 3}, {2, 3, 4}, {3, 4, 5}}
set removeIndex to 3 –1 based index
set bList to removeColumnFrom2DArray(aList, removeIndex) of me
–>  {​​​​​{​​​​​​​1, ​​​​​​​2​​​​​}, ​​​​​{​​​​​​​2, ​​​​​​​3​​​​​}, ​​​​​{​​​​​​​3, ​​​​​​​4​​​​​}​​​}

on removeColumnFrom2DArray(aList as list, removeIndex as integer)
  set newArray to {}
  
set realIndex to removeIndex – 1 –index conversion from 1-based to 0-based
  
repeat with i in aList
    set anArray to (current application’s NSMutableArray’s arrayWithArray:i)
    (
anArray’s removeObjectAtIndex:realIndex)
    
set the end of newArray to anArray as list of string or string –as anything
  end repeat
  
return newArray
end removeColumnFrom2DArray

★Click Here to Open This Script 

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

リスト中の指定アイテムを削除する(登場アイテム番号自動検索)

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:リスト中の指定アイテムを削除する(登場アイテム番号自動検索)
— Created 2017-04-11 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aTargValue to 2

set anArray to current application’s NSMutableArray’s arrayWithArray:{5, 2, 1, 3, 4}
set aInd to anArray’s indexOfObject:aTargValue

if aInd = current application’s NSNotFound or (aInd as real > 9.99999999E+8) then return {}
anArray’s removeObjectAtIndex:aInd
return anArray as list
–> {​​​​​5, ​​​​​1, ​​​​​3, ​​​​​4​​​}

★Click Here to Open This Script 

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

2つの1D List同士の消し込み

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:2つの1D List同士の消し込み
— Created 2017-10-29 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set list1 to {5, 1, 2, 3, 1, 6, 2, 7, 8, 2, 6, 5, 4}
set list2 to {6, 7, 8}
set result1 to my removeItemsInList:list2 fromList:list1
–>  {​​​​​5, ​​​​​3, ​​​​​1, ​​​​​4, ​​​​​2​​​}

set result2 to removeItems for list2 from list1
–>  {5, 3, 1, 4, 2}

set result3 to removeItemsFrom(list1, list2) of me
–>  {5, 3, 1, 4, 2}

–Objective-Cライクなパラメータ記述
on removeItemsInList:list2 fromList:list1
  set set2 to current application’s NSSet’s setWithArray:list2
  
set set1 to current application’s NSMutableSet’s setWithArray:list1
  
set1’s minusSet:set2
  
return (set1’s allObjects()) as list
end removeItemsInList:fromList:

–無意味区による装飾
on removeItems for list2 from list1
  return my removeItemsInList:list2 fromList:list1
end removeItems

–Pure AS風のパラメータ記述
on removeItemsFrom(list1, list2)
  return my removeItemsInList:list2 fromList:list1
end removeItemsFrom

★Click Here to Open This Script 

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

指定要素のみを削除(predicateでfilter) v3

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:指定要素のみを削除(predicateでfilter) v3
— Created 2017-11-03 by Takaaki Naganoya
— Modified 2017-11-05 by Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSPredicate : a reference to current application’s NSPredicate
property NSArray : a reference to current application’s NSArray

set aList to {"Apple", "Lemon", "Aple", "Lum", "Apple"}
set aTarg to "Apple" –string
set rList to removeElementsFrom1DArray(aList, aTarg) of me
–>  {"Lemon", "Aple", "Lum"}

set bList to {1, 2, 3, 1, 5}
set bTarg to 1 –number
set rList to removeElementsFrom1DArray(bList, bTarg) of me
–>  {​​​​​2, ​​​​​3, ​​​​​5​​​}

set cList to {1, 2, 3, 1, 5}
set cTarg to {1, 2, 3} –list of number
set rList to removeElementsFrom1DArray(cList, cTarg) of me
–>  {​​​​​5​​​}

set dList to {"Apple", "Lemon", "Aple", "Lum", "Apple"}
set dTarg to {"Apple", "Lemon"} –list of string
set rList to removeElementsFrom1DArray(dList, dTarg) of me
–>  {​​​​​"Aple", ​​​​​"Lum"​​​}

on removeElementsFrom1DArray(aList as list, aTarg as {number, string, list})
  set anArray to NSArray’s arrayWithArray:aList
  
  
set aClass to class of aTarg
  
if aClass = list then
    set thePred to NSPredicate’s predicateWithFormat_("NOT SELF IN %@", aTarg)
  else
    set thePred to NSPredicate’s predicateWithFormat_("SELF != %@", aTarg)
  end if
  
  
set bList to (anArray’s filteredArrayUsingPredicate:thePred) as list
  
  
return bList
end removeElementsFrom1DArray

★Click Here to Open This Script 

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

1D List中のアイテムが指定リストに入っていたら抽出

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1D List中のアイテムが指定リストに入っていたら抽出
— Created 2017-11-03 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

property NSPredicate : a reference to current application’s NSPredicate
property NSArray : a reference to current application’s NSArray

set aList to {"Apple", "Lemon", "Apple", "Water Melon"}
set aTarg to {"Apple", "Lemon"} –データの表記ゆらぎ対策に使える?

set anArray to NSArray’s arrayWithArray:aList
set aPred to NSPredicate’s predicateWithFormat_("SELF IN %@", aTarg)
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
–>  {​​​​​"Apple", ​​​​​"Lemon", ​​​​​"Apple"​​​}

★Click Here to Open This Script 

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

1D Listから条件抽出(正規表現2)

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1D Listから条件抽出(正規表現2)
— Created 2017-11-03 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
–http://piyocast.com/as/archives/4949

property NSPredicate : a reference to current application’s NSPredicate
property NSArray : a reference to current application’s NSArray

set aList to {"123456789X", "9876x", "987654321x", "1234567890", "12345X", "1234567890X", "999999999X", "1111111111", "222222222X"}

set anArray to NSArray’s arrayWithArray:aList

set aPred to NSPredicate’s predicateWithFormat:"SELF MATCHES ’\\\\d{10}|\\\\d{9}[Xx]’"
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
–>  {"123456789X", "987654321x", "1234567890", "999999999X", "1111111111", "222222222X"}

★Click Here to Open This Script 

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

1D Listから条件抽出(正規表現1)

Posted on 2月 7, 2018 by Takaaki Naganoya
AppleScript名:1D Listから条件抽出(正規表現1)
— Created 2017-11-03 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
–http://piyocast.com/as/archives/4949

property NSPredicate : a reference to current application’s NSPredicate
property NSArray : a reference to current application’s NSArray

set aList to {"TATACCATGGGCCATCATCATCATCATCATCATCATCATCATCACAG", "CGGGATCCCTATCAAGGCACCTCTTCG", "CATGCCATGGATACCAACGAGTCCGAAC", "CAT", "CATCATCATGTCT", "DOG"}

set anArray to NSArray’s arrayWithArray:aList

set aPred to NSPredicate’s predicateWithFormat:"SELF MATCHES ’.*(CAT){3,}(?!CA).*’"
set bRes to (anArray’s filteredArrayUsingPredicate:aPred) as list
–>  {​​​​​"CATCATCATGTCT"​​​}

★Click Here to Open This Script 

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

Post navigation

  • Older posts
  • Newer posts

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

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • macOS 15, Sequoia
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • Numbersで選択範囲のセルの前後の空白を削除
  • メキシカンハットの描画
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • AppleScriptによる並列処理
  • macOS 15でも変化したText to Speech環境
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • AppleScript入門③AppleScriptを使った「自動化」とは?
  • デフォルトインストールされたフォント名を取得するAppleScript
  • 【続報】macOS 15.5で特定ファイル名パターンのfileをaliasにcastすると100%クラッシュするバグ
  • Script Debuggerの開発と販売が2025年に終了
  • macOS 15 リモートApple Eventsにバグ?
  • AppleScript入門① AppleScriptってなんだろう?
  • macOS 14で変更になったOSバージョン取得APIの返り値
  • NSObjectのクラス名を取得 v2.1
  • macOS 15:スクリプトエディタのAppleScript用語辞書を確認できない
  • 有害ではなくなっていたSpaces
  • AVSpeechSynthesizerで読み上げテスト

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1391) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (195) 14.0savvy (148) 15.0savvy (137) CotEditor (66) Finder (51) Keynote (119) NSAlert (61) NSArray (51) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (53) NSDictionary (28) NSFileManager (23) NSFont (21) NSImage (41) NSJSONSerialization (21) NSMutableArray (63) NSMutableDictionary (22) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (119) NSURL (98) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (76) Pages (55) Pixelmator Pro (20) Safari (44) Script Editor (27) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Beginner
  • Benchmark
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • check sum
  • Clipboard
  • Cocoa-AppleScript Applet
  • Code Sign
  • Color
  • Custom Class
  • date
  • dialog
  • diff
  • drive
  • Droplet
  • 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
  • Localize
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • parallel processing
  • PDF
  • Peripheral
  • process
  • 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)
  • 未分類

アーカイブ

  • 2025年7月
  • 2025年6月
  • 2025年5月
  • 2025年4月
  • 2025年3月
  • 2025年2月
  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 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