AppleScript名:指定のDiskの情報を取得する |
— Created 2016-04-06 by Takaaki Naganoya — 2016 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set targDev to "/dev/disk3" –Blu-ray drive via USB set aDict to current application’s NSMutableDictionary’s alloc()’s init() try set a to do shell script "diskutil info " & targDev on error return false end try set aList to paragraphs of a repeat with i in aList set j to contents of i if j is not equal to "" then set jj to parseByDelim(j, ":") of me if (count every item of jj) is equal to 2 then copy jj to {j2, j3} set jj2 to (current application’s NSString’s stringWithString:j2) set jj3 to (current application’s NSString’s stringWithString:j3) set jjj2 to (jj2’s stringByTrimmingCharactersInSet:(current application’s NSCharacterSet’s whitespaceCharacterSet())) set jjj3 to (jj3’s stringByTrimmingCharactersInSet:(current application’s NSCharacterSet’s whitespaceCharacterSet())) (aDict’s setValue:jjj3 forKey:jjj2) end if end if end repeat return aDict as list of string or string –> {Read-Only Media:"Yes", OS Can Be Installed:"No", Volume Name:"Not applicable (no file system)", OS 9 Drivers:"No", Virtual:"No", Device Block Size:"2048 Bytes", Low Level Format:"Not supported", Removable Media:"Yes", Device / Media Name:"MATSHITA BD-MLT UJ240AS", Optical Media Erasable:"No", Optical Drive Type:"CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-R, DVD-R DL, DVD-RW, DVD-RAM, DVD+R, DVD+R DL, DVD+RW, BD-ROM, BD-R, BD-RE", Part of Whole:"disk3", Device Identifier:"disk3", Whole:"Yes", Optical Media Type:"BD-R", SMART Status:"Not Supported", Device Location:"External", Volume Free Space:"Not applicable (no file system)", Device Node:"/dev/disk3", Read-Only Volume:"Not applicable (no file system)", Media Type:"Generic", Total Size:"0 B (0 Bytes) (exactly 0 512-Byte-Units)", Media Removal:"Software-Activated", Mounted:"Not applicable (no file system)", Content (IOContent):"None", File System:"None", Protocol:"USB"} –テキストを指定デリミタでリスト化 on parseByDelim(aData, aDelim) set aText to current application’s NSString’s stringWithString:aData set aList to aText’s componentsSeparatedByString:aDelim return aList as list end parseByDelim |
More from my site
(Visited 33 times, 1 visits today)