make List of Volumes mounted

Hi,

I’m novice in AppleScript language. I’m trying to buil a script which create a dialog list with all volumes mounted. After that, the user could choose a volume in the list and the script will get the path of selected volumes and stock it in a variable.

My code is:

set volName to do shell script "ls /volumes/"
return volName

It’s work but after that. I don’t know what I have to do.

Thanks a lot,
Xavier

Try something like this:

do shell script "ls /Volumes"
get paragraphs of result
choose from list (result)

You can also use the Finder:

tell application "Finder" to get name of every disk whose ejectable is true
choose from list (result)

You can also use the “list disks” command (from Standard Additions):

list disks
choose from list (result)

Hi,

Thanks a lot Bruce… works well !!

But it remains a problem.
I use this script in an automator workflow, so I want to get selected volume name to get it’s contain, filter it, copy, etc… many automator actions. But when I put the script in an automator action, it don’t pass variable to others actions.

Per example here is my actions :

  1. script to get selected volume name
  2. get folder contain
  3. filter finder items
  4. copy finder items

I take care to add the line after you script

return "/Volumes/" & result

But Automator appears to bypass this return.
All my actions are well linked by “Use results of the previous action”

How can i do ??

Thanks

Xavier

Or maybe i have to make a list like this automator action :
Get specified finder items

It open a window with a list to add path. When we select one, it displays it with icon, name and path.

If i could create a liste like that, maybe automator would recognize my passed variable
couldn’t ?

Xavier

I just noticed this is posted in the Mac OS (9 and earlier) forum. I’m moving this to the Automator forum.

xbiron,

This should be possible without scripting in Automator. Drag the following actions in from the Finder library

Get Specified Finder Items
Eject Disk

Mount all Disks you want to eject and choose them in the Get… action. Even if all disks aren’t present when you run the workflow, Automator will eject those that are.

Kevin

Hi,

Thanks Kevin, but i don’t want to eject volume.
I want user select a volume (Compact Flash card or other Digital photos card), get photos, filter, copy, etc…

So i don’t know volume name. Just the script user who will insert a card, will be abble to select it. But to simplifize things, i want just a volume list and not a big files list with all rep and files of system !!

Thanks

Xavier

Browser: Firefox 1.0.7
Operating System: Mac OS X (10.4)

Simpler still. If the the disk is mounted, you can use a Get Specified Finder items and check the Show Action When Run option. The user click the plus button and chooses the volume. When they click continue, only the volume name should be passed to the next action. Does that do it?

Kevin

Sure i understand but I want it more simple for user.
In your case, user have to click “plus” button and select volume in a complex list with files, repertories, volumes, etc…

I want a simple list of volumes and that’s it. Not a complicated thing.
Bruce found me a easy way to get a volume list but i can’t passed selected volume name through next action.

I see 2 solutions :

  • I find the way to pass selected volume name
  • I make a select list like the “Get Specified Finder items” action

Xavier