フォルダ判定
| 固定リンク
| 固定リンク
tell application "Finder"
set aliasLibraryDirPath to (path to library folder from local domain) as alias
--> alias "Macintosh HD:Library:"
log class of aliasLibraryDirPath
-->alias
log kind of aliasLibraryDirPath as text
--> (*フォルダ*)
end tell
set strPath to "Macintosh HD:Library:"
log strPath
-->(*Macintosh HD:Library:*)
log class of strPath
-->(*text*)
set aliasPath to strPath as alias
log aliasPath
-->(*alias Macintosh HD:Library:*)
log class of aliasPath
-->(*alias*)
tell application "Finder"
set aliasLibraryDirPath to (path to library folder from user domain) as alias
--> alias "Macintosh HD:Users:ユーザー名:Library:"
log class of aliasLibraryDirPath
-->alias
log kind of aliasLibraryDirPath as text
--> (*フォルダ*)
end tell
set strLibraryDirPath to aliasLibraryDirPath as text
log strLibraryDirPath
-->(*Macintosh HD:Users:ユーザー名:Library:*)
log class of strLibraryDirPath
(*text*)
set strPath to strLibraryDirPath & "CloudStorage:OneDrive-個人用:Microsoft Edge Collections:"
log strPath
-->(*Macintosh HD:Users:ユーザー名:Library:OneDrive-個人用:Microsoft Edge Collections:*)
log class of strPath
-->(*text*)
set aliasPath to strPath as alias
log aliasPath
-->(*alias Macintosh HD:Users:ユーザー名:Library:CloudStorage:OneDrive-個人用:Microsoft Edge Collections:*)
log class of aliasPath
-->(*alias*)
set furlFilePath to choose file name
log class of furlFilePath
-->(*«class furl»*)
tell application "Finder"
set aliasDesktopDirPath to (path to desktop folder from user domain) as alias
--> alias "Macintosh HD:Users:ユーザー名:Desktop:"
log class of aliasDesktopDirPath
-->alias
log kind of aliasDesktopDirPath as text
--> (*フォルダ*)
end tell
tell application "Finder"
set aliasFolderDirPath to furlFilePath as «class furl»
log aliasFolderDirPath
--> (*file Macintosh HD:Users:ユーザー名:Desktop:名称未設定*)
log class of aliasFolderDirPath
--> (*«class furl»*)
end tell
set strFolderDirPath to aliasFolderDirPath as text
set aliasFolderDirPath to strFolderDirPath as «class furl»
set strFilePath to "Macintosh HD:Users:ユーザー名:Desktop:名称未設定.txt" as text
set furlFilePath to strFilePath as «class furl»
tell application "Finder"
set folderLibraryDirPath to folder (path to library folder from local domain)
--> folder "Library" of startup disk
log class of folderLibraryDirPath
--> folder
log kind of folderLibraryDirPath as text
--> (*フォルダ*)
end tell
tell application "Finder"
set folderDocumentationPath to (folder "Documentation" of folderLibraryDirPath)
--> folder "Documentation" of folder "Library" of startup disk
log class of folderDocumentationPath
--> folder
log kind of folderDocumentationPath as text
--> (*フォルダ*)
end tell
tell application "Finder"
set folderLibraryDirPath to folder (path to library folder from local domain)
--> folder "Library" of startup disk
log class of folderLibraryDirPath
--> folder
log kind of folderLibraryDirPath as text
--> (*フォルダ*)
end tell
tell application "Finder"
set aliasDocumentationPath to (folder "Documentation" of folderLibraryDirPath) as alias
--> alias "Macintosh HD:Library:Documentation:"
log class of aliasDocumentationPath
--> alias
log kind of aliasDocumentationPath as text
--> (*フォルダ*)
end tell
tell application "Finder"
set fileFilePath to (file "Warranty.rtf" of aliasDocumentationPath)
log class of fileFilePath
--> document file
log kind of fileFilePath as text
-->(*リッチテキスト書類*)
end tell
| 固定リンク
| 固定リンク
誤解している方が多いが
Caches内は=キャッシュなので 自動削除しないディレクトリとなります。
なので
/Users/ユーザー名/Library/Caches/Cleanup At Startup
/Users/ユーザー名/Library/Caches/TemporaryItems
内は
起動時に削除はされません
使い勝手がいいのは以下の2ポイントかな?と思います。
セキュリティ上他者が見ても大丈夫な物なら
/tmp
セキュリティ上自分だけのアクセス権で…なら
/var/folders
/var/foldersを利用する場合は
自分だけアクセス権の『C』『T』を利用する
(c=キャッシュ的な意味合い? T=テンポラリーのT)
| 固定リンク
| 固定リンク
1:Posix file
alias
https://quicktimer.cocolog-nifty.com/icefloe/2023/02/post-53f288.html
2:Posix path
3:Strings
https://quicktimer.cocolog-nifty.com/icefloe/2023/02/post-4e2867.html
4:URL
https://quicktimer.cocolog-nifty.com/icefloe/2023/02/post-738998.html
5:Javascript
https://quicktimer.cocolog-nifty.com/icefloe/2023/02/post-5ffea1.html
| 固定リンク
| 固定リンク
property refMe : a reference to current application
set strFilePath to "~/Desktop/NoName.txt" as text
(*~/Desktop/*)
set ocidFilePathStr to refMe's NSString's stringWithString:strFilePath
(*__NSCFString*)
set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
(*NSPathStore2*)
###############################
set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:ocidFilePath isDirectory:false
(*NSURL*)
log ocidFilePathURL's |path| as text
(*/Users/ユーザー名/Desktop/NoName.txt*)
log ocidFilePathURL's absoluteString() as text
(*file:///Users/ユーザー名/Desktop/NoName.txt*)
log ocidFilePathURL's absoluteURL() as text
(*Macintosh HD:Users:ユーザー名:Desktop: NoName.txt*)
###############################
####ファイル名
set ocidFileName to ocidFilePathURL's lastPathComponent()
(* NoName.txt*)
set ocidFileName to ocidFileName's stringByDeletingPathExtension()
(* NoName*)
####ベースファイル名-->ファイル名ー拡張子
set ocidBaseFileName to ocidFilePathURL's URLByDeletingPathExtension()
(*/Users/ユーザー名/Desktop/NoName*)
####拡張子
set ocidExtensionName to ocidFilePathURL's pathExtension()
(*txt*)
####コンテナディレクトリ
set ocidContainerDirURL to ocidFilePathURL's URLByDeletingLastPathComponent()
(*/Users/ユーザー名/Desktop*)
###############################
####コンテナディレクトリに新しいディレクトリ
set ocidNewDirPathURL to ocidContainerDirURL's URLByAppendingPathComponent:"NewFolder" isDirectory:true
(*/Users/ユーザー名/Desktop/NewFolder*)
####新しいディレクトリに新しいファイル
set ocidNewFilePathURL to ocidNewDirPathURL's URLByAppendingPathComponent:"NoName.txt" isDirectory:false
(*/Users/ユーザー名/Desktop/NewFolder/NoName.txt*)
| 固定リンク
#!/usr/bin/env osascript -l JavaScript
//----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
//
//
//
//
// com.cocolog-nifty.quicktimer.icefloe
//----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
//Foundation この部分は定型
ObjC.import('Foundation')
//currentApplication
let objMe = Application.currentApplication();
//scripting additions
objMe.includeStandardAdditions = true;
//NSFileManager
let objFileManager = $.NSFileManager.defaultManager;
//NSURL定義するなら
let refNSURL = $.NSURL;
//Finder
let appFinder = Application("Finder");
appFinder.includeStandardAdditions = true;
let appSystemEvent = Application("System Events");
appSystemEvent.includeStandardAdditions = true;
//アプリケーションフォルダ
let strApplicationDirPath = appFinder.pathTo("applications folder",{from:"system domain"}).toString();
console.log(strApplicationDirPath)
//System eventを使った例
var strAcrobatDirPath = appSystemEvent.folders[strApplicationDirPath + '/Adobe Acrobat DC'].posixPath();
console.log(strAcrobatDirPath)
//Pathとして結合
var strAcrobatDirPath = Path(strApplicationDirPath + '/Adobe Acrobat DC');
console.log(strAcrobatDirPath)
//テキストとして結合
var strAcrobatDirPath = strApplicationDirPath + '/Adobe Acrobat DC';
console.log(strAcrobatDirPath)
//NSURLを使った例
let ocidFilePathURL = refNSURL.fileURLWithPath('/Applications/Adobe Acrobat DC');
console.log(ocidFilePathURL.absoluteString.js)
//NSURLのRFC形式をPOSIX PATH形式に
let ocidFilePath = ocidFilePathURL.path;
console.log(ocidFilePath.js)
| 固定リンク
Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation 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 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 Apple AppleScript AppleScript Accessibility AppleScript AppKit AppleScript Applications AppleScript AppStore AppleScript Archive AppleScript Attributes AppleScript Audio AppleScript Automator AppleScript AVAsset AppleScript AVconvert AppleScript AVFoundation AppleScript AVURLAsset AppleScript BackUp AppleScript Barcode AppleScript Bash AppleScript Basic AppleScript Basic Path AppleScript Bluetooth AppleScript BOX AppleScript Browser AppleScript Calendar AppleScript CD/DVD AppleScript Choose AppleScript Chrome AppleScript CIImage AppleScript CloudStorage AppleScript Color AppleScript com.apple.LaunchServices.OpenWith AppleScript Console AppleScript Contacts AppleScript CotEditor AppleScript CURL AppleScript current application AppleScript Date&Time AppleScript delimiters AppleScript Desktop AppleScript Device AppleScript Diff AppleScript Disk AppleScript do shell script AppleScript Dock AppleScript DropBox AppleScript Droplet AppleScript eMail AppleScript Encode % AppleScript Encode Decode AppleScript Encode UTF8 AppleScript Error AppleScript EXIFData AppleScript ffmpeg AppleScript File AppleScript Finder AppleScript Firefox AppleScript Folder AppleScript Fonts AppleScript GIF AppleScript Guide AppleScript HTML AppleScript HTML Entity AppleScript Icon AppleScript Illustrator AppleScript Image Events AppleScript Image2PDF AppleScript ImageOptim AppleScript iWork AppleScript Javascript AppleScript Jedit AppleScript Json AppleScript Label AppleScript Leading Zero AppleScript List AppleScript locationd AppleScript LRC AppleScript LSSharedFileList AppleScript m3u8 AppleScript Mail AppleScript MakePDF AppleScript Map AppleScript Math AppleScript Messages AppleScript Microsoft AppleScript Microsoft Edge AppleScript Microsoft Excel AppleScript Mouse AppleScript Movie AppleScript Music AppleScript NetWork AppleScript Notes AppleScript NSArray AppleScript NSArray Sort AppleScript NSBitmapImageRep AppleScript NSBundle AppleScript NSCFBoolean AppleScript NSCharacterSet AppleScript NSColor AppleScript NSColorList AppleScript NSData AppleScript NSDictionary AppleScript NSError AppleScript NSEvent AppleScript NSFileAttributes AppleScript NSFileManager AppleScript NSFileManager enumeratorAtURL AppleScript NSFont AppleScript NSFontManager AppleScript NSGraphicsContext AppleScript NSImage AppleScript NSIndex AppleScript NSKeyedArchiver AppleScript NSKeyedUnarchiver AppleScript NSLocale AppleScript NSMutableArray AppleScript NSMutableDictionary AppleScript NSMutableString AppleScript NSNotFound AppleScript NSNumber AppleScript NSOpenPanel AppleScript NSPasteboard AppleScript NSpoint AppleScript NSPredicate AppleScript NSPrintOperation AppleScript NSRange AppleScript NSRect AppleScript NSRegularExpression AppleScript NSRunningApplication AppleScript NSScreen AppleScript NSSize AppleScript NSString AppleScript NSStringCompareOptions AppleScript NSTask AppleScript NSTimeZone AppleScript NSURL AppleScript NSURL File AppleScript NSURLBookmark AppleScript NSURLComponents AppleScript NSURLResourceKey AppleScript NSURLSession AppleScript NSUserDefaults AppleScript NSUUID AppleScript NSView AppleScript NSWorkspace AppleScript Numbers AppleScript OAuth AppleScript ObjC AppleScript OneDrive AppleScript Osax AppleScript PDF AppleScript PDFAnnotation AppleScript PDFAnnotationWidget AppleScript PDFContext AppleScript PDFDisplayBox AppleScript PDFDocumentPermissions AppleScript PDFImageRep AppleScript PDFKit AppleScript PDFnUP AppleScript PDFOutline AppleScript Photoshop AppleScript Pictures AppleScript PostScript AppleScript prefPane AppleScript Preview AppleScript Python AppleScript QR AppleScript QR Decode AppleScript QuickLook AppleScript QuickTime AppleScript record AppleScript Regular Expression AppleScript Reminders AppleScript ReName AppleScript Repeat AppleScript RTF AppleScript Safari AppleScript SaveFile AppleScript ScreenCapture AppleScript ScreenSaver AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript Sound AppleScript Spotlight AppleScript SRT AppleScript StandardAdditions AppleScript stringByApplyingTransform AppleScript Swift AppleScript System Events AppleScript System Events Plist AppleScript System Settings AppleScript TemporaryItems AppleScript Terminal AppleScript Text AppleScript Text CSV AppleScript Text MD AppleScript Text TSV AppleScript TextEdit AppleScript Translate AppleScript Trash AppleScript Twitter AppleScript UI AppleScript Unit Conversion AppleScript UTType AppleScript valueForKeyPath AppleScript Video AppleScript VisionKit AppleScript Visual Studio Code AppleScript webarchive AppleScript webp AppleScript Wifi AppleScript XML AppleScript XML EPUB AppleScript XML OPML AppleScript XML Plist AppleScript XML RSS AppleScript XML savedSearch AppleScript XML SVG AppleScript XML TTML AppleScript XML webloc AppleScript XMP AppleScript YouTube Applications CityCode github iPhone List lsappinfo Memo Music perl PlistBuddy pluginkit postalcode ReadMe SF Symbols character id SF Symbols Entity sips Skype Slack sqlite TCC Tools Typography Video Wacom Windows zoom