• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: get "type" of disk i.e. CD, DVD, zip...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get "type" of disk i.e. CD, DVD, zip...


  • Subject: Re: get "type" of disk i.e. CD, DVD, zip...
  • From: Graff <email@hidden>
  • Date: Sat, 20 Nov 2004 02:10:45 -0500

Here's one way to do it, using the shell utility "diskutil":
----
tell application "Finder"
set allDisks to name of disks
set theChoice to choose from list allDisks with prompt "Pick any disk" without multiple selections allowed and empty selection allowed
set chosenDisk to quoted form of POSIX path of ((some disk whose name is theChoice) as text)
set mediaTypes to every paragraph of (do shell script "diskutil info " & chosenDisk & " | awk '/Media Type/ { print $3 }'")


-- I still can't figure out the $%@# Applescript filter reference form so I'm doing this instead:
set typeList to {}
repeat with aType in mediaTypes
if aType does not contain "Generic" then
set typeList to typeList & aType
end if
end repeat

set AppleScript's text item delimiters to ", "
display dialog "That is a " & (typeList as text)
set AppleScript's text item delimiters to ""
end tell
----


This one will also give you an idea if the disk is on removable media or not, if it isn't then it is probably a network drive or a hard drive:
----
tell application "Finder"
set allDisks to name of disks
set theChoice to choose from list allDisks with prompt "Pick any disk" without multiple selections allowed and empty selection allowed
set chosenDisk to quoted form of POSIX path of ((some disk whose name is theChoice) as text)
set isEjectable to do shell script "diskutil info " & chosenDisk & " | awk '/Ejectable/ { print $2 }'"
if isEjectable contains "No" then
display dialog "That disk can not be ejected"
else
display dialog "That disk can be ejected"
end if
end tell
----


- Ken

On Nov 19, 2004, at 5:50 PM, Brendan Wilde wrote:

I am guessing this is really easy but haven't been able to find the answer anywhere.
I am trying to find out the type of a disk i.e. CD, DVD etc


I looked the "Finder" dict. and through the properties for a disk and came up with this,
which seems like it might work? There must be an easy method
to figure out if a disk is a CD, DVD, Hard Drive, zip etc...
(sorry if this has been brought before...)


tell application "Finder"
	set disk_ to (choose folder with prompt "Pick any disk")
	try
		set capacity_ to capacity of disk_ as text
			if capacity_ contains "E+8" then --or E+7?
			display dialog "is this a CD?"
		else if capacity_ contains "E+9" then
			display dialog "is this a DVD?"
		else if capacity_ contains "E+10" then
			display dialog "is this a hard disk?"
		end if
	end try
end tell

_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >get "type" of disk i.e. CD, DVD, zip... (From: Brendan Wilde <email@hidden>)

  • Prev by Date: Re: Deleting last item of a List
  • Next by Date: Re: Deleting last item of a List
  • Previous by thread: get "type" of disk i.e. CD, DVD, zip...
  • Next by thread: Re: Applescript-users Digest, Vol 1, Issue 213
  • Index(es):
    • Date
    • Thread