Is there a way to detect a child folder?

I need to put the path of a certain volume who has a child folder “backup”. Is there anyway to detect this child folder and then put the corresponding volume in a path? Thanks in advance.

I am not sure if the title of the topic and what you are wanting as a solution are clear, too me. But I will make an attempt to help you out.

To simply mount a volume:

try
	mount volume "cifs://volume/folder" on server "servername" as user name "user"
on error errmsg number errnum from errFrom partial result errResult to errTo
	display dialog errmsg
end try

You will need to change the volume type to match the server system you are mounting, i.e. FTP, CIFS, AFP, etc… Also, you may need to supply a password for some systems.OS

OS X already has a Automount function that looks for volumes being mounted in the /Volumes folder. When ever a volume is placed there it will attempt to mount the device based on the device drivers supplied, either by the OS or by installed driver. This is the case with Compact Flash, USB, and Firewire volumes. Not so with server volumes. They must be supplied with the mounting information. The script above gives that information.

If you could be more clear on the volume setup, that may help in determining other scripting possibilities.

I’m also not completely clear what you are trying to do but I think this may be close:

set the_disks to list disks
set child_folder to "backup"

repeat with this_disk in the_disks
	try
		set this_path to (this_disk & ":" & child_folder & ":") as string
		get this_path as alias
		if button returned of (display dialog ("The folder " & child_folder & " was found on the disk " & this_disk & "." & return & return & this_path) buttons {"Copy Path", "OK"} default button 2 with icon 1) = "Copy Path" then set the clipboard to this_path
		return
	end try
end repeat
display dialog ("The folder " & child_folder & " was not found on any mounted disks.") buttons {"OK"} default button 1 with icon 2 giving up after 10

Jon

My approach:


tell application "System Events"
	repeat with theDisk in (get disks)
		try
			tell (get contents of theDisk)
				alias "Backup"
				return path
			end tell
		end try
	end repeat
end tell

display dialog "The volume with item \"Backup\" not found"

It could also been done this way…

tell application "System Events"
	set theDisk to its name of disk
	repeat with i from 1 to (count theDisk)
		if (item i of theDisk) contains "Samsung" then
			log true
		end if
	end repeat
end tell