Проблема в том, что Mac OS Extended format
является перечисляемой константой (фактически в целочисленном значении).К нему нельзя получить доступ за пределами блока Finder
, и в приложении строка display dialog
, по-видимому, рассматривается как находящаяся вне блока телл.Вы должны привести перечисление к тексту.
Я предлагаю этот код, он использует disk
класс System Events
и перечисляет диски
set theVolumes to list folder "/Volumes"
set chosenVolume to choose from list theVolumes with prompt "Select a volume"
if chosenVolume is false then return
set chosenVolume to item 1 of chosenVolume
tell application "System Events" to set volumeFormat to (format of disk chosenVolume as text)
display dialog chosenVolume & " is formatted as " & volumeFormat
Редактировать: Приведенный выше код явно не работает из-за ошибки.
Это альтернатива с небольшой помощью AppleScriptObjC ифундамент основы
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
set theVolumes to list folder "/Volumes"
set chosenVolume to choose from list theVolumes with prompt "Select a volume"
if chosenVolume is false then return
set chosenVolume to item 1 of chosenVolume
tell application "System Events" to set volumeURL to URL of disk chosenVolume
set theURL to current application's NSURL's alloc()'s initWithString:volumeURL
set {success, theFormat, theError} to theURL's getResourceValue:(reference) forKey:(current application's NSURLVolumeLocalizedFormatDescriptionKey) |error|:(reference)
if success then
display dialog chosenVolume & " is formatted as " & (theFormat as text)
else
display dialog theError's localizedDescription() as text
end if