AppeScript: Files von Alias unterscheiden

madu

madu

Aktives Mitglied
Thread Starter
Dabei seit
16.11.2005
Beiträge
4.682
Reaktionspunkte
577
Ich suche eine Möglichkeit, mit AppleScript in einer Liste von Dateien (Ordnerinhalt) "normale" Files von Alias zu unterscheiden.
Noch schöner wäre, die Alias zu unterteilen in Verknüpfungen zu Ordnern und Verknüpfungen zu Files.

Also Ausgangspunkt = Liste mit Ordnerinhalt
Resultat:
Liste 1 (Verknüpfungen zu Ordnern)
Liste 2 (Verknüpfungen zu Files)
Liste 3 (alles andere)

Ist das irgendwie möglich?

Danke :)
 
Ist das irgendwie möglich?
Klar.

Siehe unten. Das dürfte Deine Probleme lösen.
In ne Methode, die das abnudelt mußt Du es selbst warpen.

Bitte.

Viele Grüße

Code:
--

set aFile to (POSIX file "/Users/test/Desktop/some alias") as string

--

tell application "System Events"
	
	-- 
	
	set ItemInfo to properties of item aFile
	
	if ((kind of ItemInfo) is not "Alias") then
		
		return
		
	end if
	
	--
	
end tell

--

tell application "Finder"
	
	--
	
	set aFile to (original item of file aFile) as string
	
	--
	
end tell

--

tell application "System Events"
	
	-- 
	
	set ItemInfo to properties of item aFile
	
	--
	
	return (class of ItemInfo)
	
	--
	
end tell

--
 
  • Gefällt mir
Reaktionen: madu
Super!! :)

Vielen Dank! Das hat sehr geholfen :)

hier die fertige Routine, evt. kann das mal noch jemand gebrauchen:

Code:
set folderAlias_list to {}
set fileAlias_list to {}
set files_list to {}

tell application "Finder"
	set AllFiles to (name of every file of desktop) as list
	repeat with my_item in AllFiles
		set ItemInfo to properties of item my_item
		if ((kind of ItemInfo) is "Alias") then
			set aFile to (original item of file my_item) as string
			set FileInfo to properties of item aFile
			if (class of FileInfo) is folder then
				set folderAlias_list to folderAlias_list & my_item
			else
				set fileAlias_list to fileAlias_list & my_item
			end if
		else
			set files_list to files_list & my_item
		end if
	end repeat
end tell
 
Schau dir mal den whose-Ausdruck an:

Code:
[B]tell [/B][COLOR=#0433FF][FONT=Verdana][I]application[/I][/FONT][/COLOR][FONT=Verdana] "Finder"
[/FONT][FONT=Verdana]    [B]set[/B] [COLOR=#4f8f00]theFolder[/COLOR] [B]to[/B] [COLOR=#0433ff][I]folder[/I][/COLOR] "Test" [B]of[/B] [COLOR=#812fdc]desktop[/COLOR][/FONT]
[COLOR=#942193][FONT=Menlo]    [/FONT][/COLOR]
[FONT=Verdana]    [B]set[/B] [COLOR=#4f8f00]aliasFiles[/COLOR] [B]to[/B] [COLOR=#0433ff][I]alias files[/I][/COLOR] [B]of[/B] [COLOR=#4f8f00]theFolder[/COLOR] [B]whose[/B] [COLOR=#812fdc]file type[/COLOR] [B]is[/B] "alis"[/FONT]
[FONT=Verdana]    [B]set[/B] [COLOR=#4f8f00]aliasFolders[/COLOR] [B]to[/B] [COLOR=#0433ff][I]alias files[/I][/COLOR] [B]of[/B] [COLOR=#4f8f00]theFolder[/COLOR] [B]whose[/B] [COLOR=#812fdc]file type[/COLOR] [B]is[/B] "fdrp"[/FONT]
[FONT=Verdana]    [B]set[/B] [COLOR=#4f8f00]otherItems[/COLOR] [B]to[/B] [COLOR=#0433ff][I]items[/I][/COLOR] [B]of[/B] [COLOR=#4f8f00]theFolder[/COLOR] [B]whose[/B] [COLOR=#012fbe][I]kind[/I][/COLOR] [B]is[/B] [B]not[/B] "Alias"[/FONT]
[FONT=Verdana][B]end[/B] [B]tell[/B][/FONT]
 
  • Gefällt mir
Reaktionen: madu
Danke!
Sieht nochmals 'ne ganze Runde simpler aus :)

Werde ich morgen mal testen.
Gute Nacht :)
 
Variante:
Code:
tell application "Finder"
	set folderList to every folder of desktop
	set aliasList to every alias file of desktop
	set documentList to every document file of desktop
end tell

gruß
maceis
 
Zurück
Oben Unten