[AS] Droplet funktioniert nicht mit mehreren Files oder kompl. Ordner

Bozol

Aktives Mitglied
Thread Starter
Dabei seit
16.07.2003
Beiträge
3.483
Reaktionspunkte
2.195
Hi,
ich habe mir etwas für Hazel zusammen gestrickt um meine Videos farblich nach Auflösung zu sortieren. Da Hazel aber nicht so recht mit Netzlaufwerken mag dachte ich mir ich mach aus meinem Script ein Droplet und ziehe die Files oder Ordner einfach drüber, zumal ich das eh nur einmal machen muss um meine Sammlung dahingehend zu checken da ja neue Aufnahmen vorm Endlagern auf dem NAS schon beim Erstellen geprüft werden.

Leider klappt es nicht so wie ich es mir vorgestellt habe. Wenn ich ein File drüber ziehe klappt es wie gewollt, nur bei mehreren Files oder einem Ordner kommt von AS eine Fehlermeldung wie z.B.:
attachment.php


So wie es für mich als Noob aussieht nimmt AS die einzelnen Dateinamen als ein einziges File und findet natürlich nichts. Wie kann ich das vermeiden?

Danke im Voraus und Gruss, Fred.

Hier noch mein Script:
Code:
on open theFile
	set theFile to theFile as string
	
	
	
	set the_command to quoted form of "/Volumes/Work/fred/Library/Scripts/mediainfo"
	
	set posix_path to POSIX path of theFile
	set the_width to do shell script the_command & space & quoted form of posix_path & " | grep \"Width\" | sed 's/[^0-9]//g'"
	log the_width
	if the_width as real is greater than 1280 then
		--Full HD Video grün
		tell application "Finder" to set label index of (theFile as alias) to 6
		
	else if the_width as real is greater than 720 then
		--HD Ready Video gelb
		tell application "Finder" to set label index of (theFile as alias) to 3
		
	else
		--SD Video rot
		tell application "Finder" to set label index of (theFile as alias) to 2
	end if
end open
 

Anhänge

  • Screenshot 2012-06-01 um 18.54.51.JPG
    Screenshot 2012-06-01 um 18.54.51.JPG
    29 KB · Aufrufe: 113
klar, dass das nicht funktioniert.
du nimmst ja auch nur ein file und nicht alle:

Code:
on open DropList
	repeat with objectRef in DropList
        //hier was mit objectRef anstellen
	end repeat
end open
 
Danke schön, nun funktioniert es auch mit mehreren Files. Leider aber nicht wenn ich einen Ordner darauf ziehe. Dann kommt es zur folgenden Fehlermeldung:

attachment.php


Das Script habe ich jetzt wie folgt verändert:
Code:
on open DropList
	repeat with objectRef in DropList
		set the_command to quoted form of "/Volumes/Work/fred/Library/Scripts/mediainfo"
		
		set posix_path to POSIX path of objectRef
		set the_width to do shell script the_command & space & quoted form of posix_path & " | grep \"Width\" | sed 's/[^0-9]//g'"
		log the_width
		if the_width as real is greater than 1280 then
			--Full HD Video grün
			tell application "Finder" to set label index of (objectRef as alias) to 6
			
		else if the_width as real is greater than 720 then
			--HD Ready Video gelb
			tell application "Finder" to set label index of (objectRef as alias) to 3
			
		else
			--SD Video rot
			tell application "Finder" to set label index of (objectRef as alias) to 2
		end if
	end repeat
end open
Kann man das irgendwie noch lösen? Ansonsten ziehe ich halt die Files "per Hand" ins Droplet rein. Es wäre halt bequemer wenn es auch mit Ordnern/Unterordnern funktionieren würde. :)

Danke, Fred.
 

Anhänge

  • Screenshot 2012-06-01 um 20.02.08.JPG
    Screenshot 2012-06-01 um 20.02.08.JPG
    23,1 KB · Aufrufe: 82
So kannst du einen Ordner auswählen und alle Dateien inklusive Unterordner werden markiert.

Code:
[FONT="Verdana"][size=2][b]set[/b] [color=#3F7F00]myFolder[/color] [b]to[/b] [color=#0016B0][b]choose folder[/b][/color]
[b]set[/b] [color=#3F7F00]fileList[/color] [b]to[/b] ([color=#0016B0][b]do shell script[/b][/color] "find " & [color=#6C04D4]quoted form[/color] [b]of[/b] [color=#6C04D4]POSIX path[/color] [b]of[/b] [color=#3F7F00]myFolder[/color] & " -type f ! -name '\\.'* | sed 's/\\/\\//\\//g'")

[b]repeat[/b] [b]with[/b] [color=#3F7F00]objectRef[/color] [b]in[/b] [b]every[/b] [color=#0000FF][i]paragraph[/i][/color] [b]of[/b] [color=#3F7F00]fileList[/color]
	[b]set[/b] [color=#3F7F00]the_command[/color] [b]to[/b] [color=#6C04D4]quoted form[/color] [b]of[/b] "/Volumes/Work/fred/Library/Scripts/mediainfo"
	
	
	[b]set[/b] [color=#3F7F00]the_width[/color] [b]to[/b] [color=#0016B0][b]do shell script[/b][/color] [color=#3F7F00]the_command[/color] & [color=#6C04D4]space[/color] & [color=#6C04D4]quoted form[/color] [b]of[/b] ([color=#3F7F00]objectRef[/color] [b]as[/b] [color=#0000FF][i]text[/i][/color]) & " | grep \"Width\" | sed 's/[^0-9]//g'"
	[color=#0000FF][b]log[/b][/color] [color=#3F7F00]the_width[/color]
	[b]if[/b] [color=#3F7F00]the_width[/color] [b]as[/b] [color=#0000FF][i]real[/i][/color] [b]is[/b] [b]greater than[/b] 1280 [b]then[/b]
		[color=#4C4D4D]--Full HD Video grün[/color]
		[b]tell[/b] [color=#0000FF][i]application[/i][/color] "Finder" [b]to[/b] [b]set[/b] [color=#6C04D4]label index[/color] [b]of[/b] ([color=#0016B0][i]POSIX file[/i][/color] ([color=#3F7F00]objectRef[/color] [b]as[/b] [color=#0000FF][i]text[/i][/color]) [b]as[/b] [color=#0000FF][i]alias[/i][/color]) [b]to[/b] 6
		
	[b]else[/b] [b]if[/b] [color=#3F7F00]the_width[/color] [b]as[/b] [color=#0000FF][i]real[/i][/color] [b]is[/b] [b]greater than[/b] 720 [b]then[/b]
		[color=#4C4D4D]--HD Ready Video gelb[/color]
		[b]tell[/b] [color=#0000FF][i]application[/i][/color] "Finder" [b]to[/b] [b]set[/b] [color=#6C04D4]label index[/color] [b]of[/b] ([color=#0016B0][i]POSIX file[/i][/color] ([color=#3F7F00]objectRef[/color] [b]as[/b] [color=#0000FF][i]text[/i][/color]) [b]as[/b] [color=#0000FF][i]alias[/i][/color]) [b]to[/b] 3
		
	[b]else[/b]
		[color=#4C4D4D]--SD Video rot[/color]
		[b]tell[/b] [color=#0000FF][i]application[/i][/color] "Finder" [b]to[/b] [b]set[/b] [color=#6C04D4]label index[/color] [b]of[/b] ([color=#0016B0][i]POSIX file[/i][/color] ([color=#3F7F00]objectRef[/color] [b]as[/b] [color=#0000FF][i]text[/i][/color]) [b]as[/b] [color=#0000FF][i]alias[/i][/color]) [b]to[/b] 2
	[b]end[/b] [b]if[/b]
[b]end[/b] [b]repeat[/b]
[/size][/FONT]
 
Danke schön Pill, jetzt klappts. :)
 
Zurück
Oben Unten