[AppleScript] スクリプトに引数を渡す
| 固定リンク
| 固定リンク
Accounts.framework
AddressBook.framework
AppKit.framework
AppleScriptKit.framework
AppleScriptObjC.framework
ApplicationServices.framework
AudioUnit.framework
AudioVideoBridging.framework
Automator.framework
AVFoundation.framework
AVKit.framework
CalendarStore.framework
CloudKit.framework
Collaboration.framework
Contacts.framework
ContactsUI.framework
CoreAudio.framework
CoreAudioKit.framework
CoreBluetooth.framework
CoreData.framework
CoreImage.framework
CoreLocation.framework
CoreMediaIO.framework
CoreMIDI.framework
CoreTelephony.framework
CoreWLAN.framework
CryptoTokenKit.framework
DiscRecording.framework
DiscRecordingUI.framework
EventKit.framework
ExceptionHandling.framework
FinderSync.framework
Foundation.framework
GameController.framework
GameKit.framework
GameplayKit.framework
GLKit.framework
ImageCaptureCore.framework
IMServicePlugIn.framework
InputMethodKit.framework
InstallerPlugins.framework
InstantMessage.framework
IOBluetooth.framework
IOBluetoothUI.framework
IOKit.framework
JavaFrameEmbedding.framework
JavaScriptCore.framework
JavaVM.framework
Kernel.framework
LocalAuthentication.framework
MapKit.framework
MediaLibrary.framework
Metal.framework
MetalKit.framework
ModelIO.framework
MultipeerConnectivity.framework
NetworkExtension.framework
NotificationCenter.framework
OpenDirectory.framework
OSAKit.framework
Photos.framework
PreferencePanes.framework
PubSub.framework
Python.framework
QTKit.framework
Quartz.framework
QuartzCore.framework
SceneKit.framework
ScreenSaver.framework
Scripting.framework
ScriptingBridge.framework
SecurityFoundation.framework
SecurityInterface.framework
Social.framework
SpriteKit.framework
StoreKit.framework
SyncServices.framework
WebKit.framework
| 固定リンク
エイリアスかシンボリックリンクか
ファイルかフォルダかの判定
| 固定リンク
| 固定リンク
| 固定リンク
use AppleScript version "2.8"
use framework "Foundation"
use framework "PDFKit"
use scripting additions
property refMe : a reference to current application
set aliasFile to (choose file with prompt "PDFファイルを選んでください" default location (path to desktop folder from user domain) of type {"com.adobe.pdf"} with invisibles and showing package contents without multiple selections allowed) as alias
-->alias
set strFilePath to POSIX path of aliasFile
set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
####ページ数を数える
set ocidPDFDocument to refMe's PDFDocument's alloc()'s initWithURL:(ocidFilePathURL)
set numPdfPageCnt to ocidPDFDocument's pageCount()
log numPdfPageCnt
numPdfPageCnt
行番号 | ソース |
---|---|
001 | #! /usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | # |
005 | # |
006 | # |
007 | # com.cocolog-nifty.quicktimer.icefloe |
008 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
009 | |
010 | use AppleScript version "2.8" |
011 | use framework "Foundation" |
012 | use framework "PDFKit" |
013 | use scripting additions |
014 | |
015 | property refMe : a reference to current application |
016 | |
017 | |
018 | set aliasFile to (choose file with prompt "PDFファイルを選んでください" default location (path to desktop folder from user domain) of type {"com.adobe.pdf"} with invisibles and showing package contents without multiple selections allowed) as alias |
019 | -->alias |
020 | set strFilePath to POSIX path of aliasFile |
021 | set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath) |
022 | set ocidFilePath to ocidFilePathStr's stringByStandardizingPath() |
023 | set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false) |
024 | |
025 | ####ページ数を数える |
026 | |
027 | set ocidPDFDocument to refMe's PDFDocument's alloc()'s initWithURL:(ocidFilePathURL) |
028 | set numPdfPageCnt to ocidPDFDocument's pageCount() |
029 | |
030 | log numPdfPageCnt |
031 | numPdfPageCnt |
AppleScriptで生成しました |
| 固定リンク
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
###元のテキスト
set strFilePath to "/System/Applications/Preview.app/Contents/Info.plist"
###NSStringテキスト
set objFilePath to objNSString's stringWithString:strFilePath
log objFilePath
--->«class ocid» id «data optr00000000802A6E0200600000»
log objFilePath as text
--->/System/Applications/Preview.app/Contents/Info.plist
log objFilePath's className() as text
-->__NSCFString
| 固定リンク
Foundation
https://developer.apple.com/documentation/foundation
AppleScript ObjC
https://developer.apple.com/library/archive/releasenotes/ScriptingAutomation/RN-AppleScriptObjC/index.html
| 固定リンク
Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom