AppleScript名:アプリケーションバンドル内のファイルパスを取得する |
use AppleScript version "2.4" use scripting additions use framework "Foundation" property |NSURL| : a reference to current application’s |NSURL| property NSFileManager : a reference to current application’s NSFileManager set aRes to getPathsIn_maxfiles_("/Applications/Safari.app", 4096) –> {"/Applications/Safari.app/Contents", "/Applications/Safari.app/Contents/_CodeSignature", "/Applications/Safari.app/Contents/_CodeSignature/CodeResources", …. — Example of file manager directory enumeration on getPathsIn:folderPath maxfiles:MaxNum script spd property aList : {} end script set aList of spd to {} set theNSURL to |NSURL|’s fileURLWithPath:folderPath set theNSFileManager to NSFileManager’s new() — get URL enumerator set theNSFileEnumerator to theNSFileManager’s enumeratorAtURL:theNSURL includingPropertiesForKeys:{} options:0 errorHandler:(missing value) repeat with i from 1 to MaxNum — arbitrary number — get next URL in enumerator set anNSURL to theNSFileEnumerator’s nextObject() if anNSURL is missing value then exit repeat — missing value means there are no more set the end of (aList of spd) to (anNSURL’s |path|() as text) end repeat return (aList of spd) end getPathsIn:maxfiles: |
(Visited 50 times, 1 visits today)