TemporaryItems

テンポラリーフォルダ /var/folders


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# com.cocolog-nifty.quicktimer.icefloe
004----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
005
006tell application "System Events"
007  tell application "Finder"
008    set aliasContainerDir to container of (path to temporary items folder from user domain) as alias
009  end tell
010  log (POSIX path of aliasContainerDir) as text
011end tell
012
013---
014set strCommandText to ("/bin/bash -c '/usr/bin/dirname \"$(/usr/bin/mktemp -d)\"'") as text
015log strCommandText
016log (do shell script strCommandText) as text
017
018---
019#この記述だとパスがクローズで終わるケースがある(環境依存)
020set strCommandText to ("/bin/zsh -c '/bin/echo $TMPDIR'") as text
021log strCommandText
022log (do shell script strCommandText) as text
023
024---
025use AppleScript version "2.8"
026use framework "Foundation"
027use scripting additions
028set appFileManager to current application's NSFileManager's defaultManager()
029set ocidTempDirURL to appFileManager's temporaryDirectory()
030log ocidTempDirURL's |path|() as text
031
032---
033#この記述だとパスがクローズで終わるケースがある(環境依存)
034set ocidTempDirPath to current application's NSTemporaryDirectory()
035log ocidTempDirPath as text
AppleScriptで生成しました

|

TemporaryItemsを開く


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
error number -128
com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

###テンポラリーのNSURL
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory()
set ocidTemporaryItemsURL to ocidTemporaryDirPathURL's URLByAppendingPathComponent:("TemporaryItems") isDirectory:true
###有無チェック
set bollExist to appFileManager's fileExistsAtPath:(ocidTemporaryItemsURL's |path|) isDirectory:true
if bollExist is false then
  ###なければフォルダを作る
  set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocidAttrDict's setValue:("511") forKey:(refMe's NSFilePosixPermissions)
  set listBoolMakeDir to objFileManager's createDirectoryAtURL:(ocidTemporaryItemsURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error|:(reference)
end if

###URLを開く
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
appShardWorkspace's activateFileViewerSelectingURLs:{ocidTemporaryItemsURL}
###ヴューをリストビューにする
tell application "Finder"
  tell front window
    set current view to list view
    set toolbar visible to true
    set statusbar visible to true
    set pathbar visible to true
  end tell
end tell

|

テンポラリーを開く


【スクリプトエディタで開く】|

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
error number -128
com.cocolog-nifty.quicktimer.icefloe
*)
#
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application

###テンポラリーのNSURL
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory()
###URLを開く
set appShardWorkspace to refMe's NSWorkspace's sharedWorkspace()
appShardWorkspace's activateFileViewerSelectingURLs:{ocidTemporaryDirPathURL}
###ヴューをリストビューにする
tell application "Finder"
  tell front window
    set current view to list view
    set toolbar visible to true
    set statusbar visible to true
    set pathbar visible to true
  end tell
end tell

|

[NSTemporaryDirectory]テンポラリーディレクトリ


【スクリプトエディタで開く】|

#!/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 refMe : a reference to current application

###テンポラリディレクトリ(起動時に削除)NSURL
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory()
log ocidTemporaryDirPathURL's |path|() as text
-->(*/var/folders/XX/XXX-XXX/T*)

###テンポラリディレクトリ(起動時に削除) NSCFString
set ocidTemporaryDirPath to (refMe's NSTemporaryDirectory())
log ocidTemporaryDirPath as text
-->(*/var/folders/XX/XXX-XXX/T/*)

###Cleanup At Startup(起動時に削除) NSURL
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory()
set ocidContainerDirURL to ocidTemporaryDirPathURL's URLByDeletingLastPathComponent()
set ocidCleanupDirPathURL to ocidContainerDirURL's URLByAppendingPathComponent:("Cleanup At Startup") isDirectory:true
set listBoolMakeDir to appFileManager's createDirectoryAtURL:(ocidCleanupDirPathURL) withIntermediateDirectories:true attributes:(missing value) |error|:(reference)
log ocidCleanupDirPathURL's |path|() as text
-->(*/var/folders/XX/XXX-XXX/Cleanup At Startup*)

####キャッシュディレクトリ(起動時に保持) NSURL
set listUserLibraryPath to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidUserLibraryPathURL to listUserLibraryPath's firstObject()
set ocidCachesDirPathURL to ocidUserLibraryPathURL's URLByAppendingPathComponent:("Caches") isDirectory:true
log ocidCachesDirPathURL's |path|() as text
--> $HOME/Library/Caches

###キャッシュディレクトリ(起動時に保持) NSURL
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidTemporaryDirPathURL to appFileManager's temporaryDirectory()
set ocidContainerDirURL to ocidTemporaryDirPathURL's URLByDeletingLastPathComponent()
set ocidCachesDirPathURL to ocidContainerDirURL's URLByAppendingPathComponent:("C") isDirectory:true
log ocidCachesDirPathURL's |path|() as text
-->(*/var/folders/XX/XXX-XXX/C*)

###従来方式 Tの中のTemporaryItemsを指しています
set aliasTemporaryItems to path to temporary items from user domain as alias
-->(*/var/folders/XX/XXX-XXX/T/TemporaryItems*)
tell application "Finder"
  set aliasCachesFolder to (folder "Caches" of folder (path to library folder from user domain)) as alias
end tell
--> $HOME/Library/Caches

|

その他のカテゴリー

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 VMware Fusion 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