I can’t seem to specify what format I want to be singled out. I looked up the Finder dictionary and sure enough there is the “format” properties of a disk, i just cant use them. Does anyone see the problem with this?
tell application "Finder"
set dl to get every disk of desktop
set dc to count every disk of desktop
set rl to 2
set dc to dc - 1
repeat dc times
set formatd to get format of disk rl of desktop
if formatd is "MS-DOS format" then
display dialog "dos"
// do whatever other finder action i want to happen, in this case eject the dos formatted drives (jump drives)
end if
set rl to rl + 1
end repeat
end tell
Model: MacBook Pro
AppleScript: lateset
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
I think you may have come across a small Applescript bug. This works to find ‘Mac OS Extended format’ disks (as do all the other formats I tried):
tell application "Finder"
set myDisks to disks
repeat with myDisk in myDisks
set formatd to format of myDisk
if formatd is Mac OS Extended format then
display dialog "Mac OSX"
-- do whatever
end if
end repeat
end tell
But this doesn’t compile:
tell application "Finder"
set myDisks to disks
repeat with myDisk in myDisks
set formatd to format of myDisk
if formatd is MS-DOS format then
display dialog "dos"
-- do whatever
end if
end repeat
end tell
What do you get if you mount a DOS disk and run this?
MS-DOS format is a keyword, so it shouldn’t be in quotes. That said, the term rather stupidly doesn’t compile! (The problem’s the hyphen, it think.) What might work for you is this:
tell application "Finder"
-- Blah blah blah,
set formatd to format of disk rl
if formatd is (run script "«constant ****dfms»") then
display dialog "dos"
-- etc.
end if
end tell
«constant ****dfms» is apparently the chevron code for MS-DOS format and the run script command compiles it from the string on the fly. You could also write it directly (without quotes) into the script, within a Finder tell block, and you’d see the keyword when you compiled the script. However, you might not then be able to recompile the script after an edit.
What you could do instead, to avoid using run script each time round the repeat, would be write «constant ****dfms» into the script before the Finder tell block (so that no attempt is made to compile it into the Finder keyword) and assign it to a variable. A property at the top of the script would do nicely:
property MSDOSformat : «constant ****dfms»
tell application "Finder"
-- Blah blah blah,
set formatd to format of disk rl
if formatd is MSDOSformat then
display dialog "dos"
-- etc.
end if
end tell
“«” and “»” are the chevron characters, option-\ and shift-option-\ on English keyboards.