« [valueForKeyPath]path | トップページ | [valueForKeyPath] relativePath »

[valueForKeyPath] absoluteString

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSURL : a reference to objMe's NSURL

property objNSArray : a reference to objMe's NSArray
property objNSMutableArray : a reference to objMe's NSMutableArray

set objFileManager to objMe's NSFileManager's defaultManager()

#####
set ocidNSURLIsAliasFileKey to objMe's NSURLIsAliasFileKey
set ocidNSURLIsRegularFileKey to objMe's NSURLIsRegularFileKey
set ocidNSURLFileSizeKey to objMe's NSURLFileSizeKey
#####

try
set listAliasDir to (choose folder "画像が入っているフォルダを選んでください" with prompt "フォルダを選択してください" default location (path to desktop folder from user domain) with multiple selections allowed without invisibles and showing package contents)
on error
log "エラーしました"
return
end try


######フォルダ毎の処理
repeat with objAliasDir in listAliasDir

###エリアス
set aliasAliasDir to objAliasDir as alias
###パス
set strDirPath to POSIX path of aliasAliasDir as text
###NSStringテキスト
set ocidDirPath to (objNSString's stringWithString:strDirPath)
#####NSURL NSStringURL
set ocidUrlPath to (objNSURL's fileURLWithPath:ocidDirPath)
###フォルダの内容をリストで取得
set objContentsArray to (objFileManager's contentsOfDirectoryAtURL:ocidUrlPath includingPropertiesForKeys:{ocidNSURLIsAliasFileKey} options:(4) |error|:(missing value))
###可変リストに変更
set ocidNSArrayM to (objNSMutableArray's arrayWithArray:objContentsArray)
###ファイルパスリストに変更
set ocidNSArrayMpath to (ocidNSArrayM's valueForKeyPath:"absoluteString")
###並び替え
set ocidSortedArray to (ocidNSArrayMpath's sortedArrayUsingSelector:"compare:")
log ocidSortedArray's className() as text
log ocidSortedArray as list
###並び変わった順
repeat with objSortedArray in ocidSortedArray
log objSortedArray as text
--->>ここに順番に処理する操作等を記述する
end repeat

(*file:///Users/Shared/Desktop/1280x720/1280x720.001.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.002.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.003.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.004.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.005.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.006.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.007.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.008.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.009.png*)
(*file:///Users/Shared/Desktop/1280x720/1280x720.010.png*)
end repeat

|

« [valueForKeyPath]path | トップページ | [valueForKeyPath] relativePath »

AppleScript NSArray」カテゴリの記事

AppleScript Sort」カテゴリの記事