[Applescript] Interne und externe Festplatten umounten und Ausnahmen

tisco_over

Aktives Mitglied
Thread Starter
Dabei seit
06.12.2003
Beiträge
330
Reaktionspunkte
1
Hallo liebe Macuser Gemeinde,

ich hab mal wieder eine kleine Applescript Frage. Ich habe auf meinem MacPro zwei Betriebssysteme laufen inkl. mehrere Platten. Ich möchte jetzt gerne automatisch Platten unmounten wenn ich mit einem der beiden OSX Systeme starte. Folgenden Code hab ich schon:

Code:
property exceptions : "MacProHD" & "BackupMBHD" & "MedienHD" --Add exceptions here.

set the_items to do shell script ("ls /Volumes/")
tell application "Finder"
	repeat with each_volume in (every paragraph of the_items as list)
		set each_volume to each_volume as string
		set the_path to (":Volumes:" & each_volume) as alias
		if exceptions does not contain each_volume then
			do shell script "diskutil unmount " & each_volume
		end if
	end repeat
end tell

Funktioniert auch wunderbar - bis auf die "Macintosh HD" Platte. Ich denke das eventuell das Leerzeichen Probleme macht.

Kann mir da bitte wer weiterhelfen?

Danke,
tisco
 
Ich denke das eventuell das Leerzeichen Probleme macht.

So ist es :)
Ich wundere mich allerdings, daß das Script so wie Du es gepostet hast ansonsten funktioniert hat:
Diese Zeile
PHP:
set the_path to (":Volumes:" & each_volume) as alias
sollte wohl ursprünglich den Pfad für den Unix-Befehl unmount erstellen, aber dann wird die Variabile the_path - die vor allem kein alias, sondern ein Unix-Pfad mit "/" sein muß - gar nicht mehr benutzt ...

Eventuelle Leerzeichen in den Pfaden sollte man mit quoted form of abfangen, dann klappts:
PHP:
property exceptions : "MacProHD" & "BackupMBHD" & "MedienHD" --Add exceptions here.

set the_items to do shell script ("ls /Volumes/")

--tell application "Finder" -- den "Finder" brauchen wir nicht für diese Operation
repeat with each_volume in (every paragraph of the_items as list)
	set each_volume to each_volume as string
	-- set the_path to (":Volumes:" & each_volume) as alias
	set the_path to ("/Volumes/" & each_volume)
	if exceptions does not contain each_volume then
		set unixUnmount to ("diskutil unmount " & quoted form of the_path)
		display dialog unixUnmount
		--do shell script unixUnmount
	end if
end repeat
--end tell

Good scripting
Farid
 
Danke für die Hilfe - ich habe den Code jetzt so umgesetzt:

Code:
property exceptions : "MacProHD" & "BackupMBHD" & "MedienHD" --Add exceptions here.

set the_items to do shell script ("ls /Volumes/")
repeat with each_volume in (every paragraph of the_items as list)
	set each_volume to each_volume as string
	set the_path to ("/Volumes/" & each_volume)
	if exceptions does not contain each_volume then
		do shell script "diskutil unmount " & quoted form of the_path
	end if
end repeat

lg tisco
 
Zurück
Oben Unten