Mit AS einen Alias anlegen

goegg-art

Mitglied
Thread Starter
Registriert
04.08.2005
Beiträge
34
Reaktionspunkte
2
Hallo miteinander,

Ich habe ein AppleScript welches mir beim Download
einen Ordner erstellt (sofern nicht schon vorhanden) und mit Datum beschriftet und die Downloads dann da reinlegt. ( als Ordner-Aktion)
Beispiel:2009-10-01
Soweit ist alles I.O. das Script funktioniert bestens.

Ich suche nun nach einer Lösung die mir einen Alias des Aktuellen Ordner ins Dock und/oder die Seitenleiste "zaubert" , dabei natürlich den alten Alias
überschreibt/löscht.

Ist so was möglich und für ungeübte wie mich Lösbar?

Besten Dank für Hilfreiche Inputs/Ideen wo ich ansetzen kann.
 
Hallo,

ich sehe nur den Weg über die com.apple.dock.plist

Du könntest dem Eintrag "persistent-others" ein weiteres Element hinzufügen.
Das Problem ist, dass das alles nicht so einfach ist. Vielleicht findest Du ein paar Tipps im Netz dazu.
Ich glaube, dass diese Plist nicht von Apple dokumentiert ist.

Meinem Wissenstand nach gibt es noch keine Events um das Dock mit AS direkt anzusprechen.
Kann sich aber auch geändert haben.

Viele Grüße
 
Für den Schreibtisch sollte sowas gehen:
PHP:
tell application "Finder"
make new alias file to [pfad_zu_deinem_file] at desktop
end tell
Good scripting
Farid
 
Vielen Dank schon mal...

Doch leider habe ich gemerkt das ich zu den "AS-Rookies" gehöre :-(
Natürlich werde ich es weiterhin Probieren.. ist aber eben nur ein "gepröble"
ohne wissen...

Ich stell das Script mal hier rein, wer Lust hat kann weiterhelfen ;-)
PHP:
property open_folder : true
property touch_file : false
property time_fmt : 1
property bring_to_front : true
property organized_folder : ""
property ignore_kinds : {"Safari download", "Finder Document"}
property date_fmt : "+%Y-%m-%d" -- BE VERY CAREFUL HERE! This string is execute in the UNIX shell. The wrong command string could be bad.


on run
	
	display dialog "Do you want to show the folder when new items are added?" buttons {"Don't Show", "Show"} default button 2
	if the button returned of the result is "Don't Show" then
		set open_folder to false
	else
		set open_folder to true
	end if
	
	display dialog " Do you want to make the Finder active when new items are added?" buttons {"Don't Activate", "Activate"} default button 2
	if the button returned of the result is "Don't Activate" then
		set bring_to_front to false
	else
		set bring_to_front to true
	end if
	
	display dialog "Do you want to set the modification date to the time the items were added?" buttons {"Change Modification Date", "Don't Change Modification Date"} default button 2
	if the button returned of the result is "Don't Change Modification Date" then
		set touch_file to false
	else
		set touch_file to true
	end if
	
end run

on open of the_files
	if (organized_folder is equal to "") then
		set_organized_folder()
	end if
	
	tell application "Finder" to move the_files to organized_folder
end open

on set_organized_folder()
	set organized_folder to (choose folder)
	
end set_organized_folder


on adding folder items to this_folder after receiving added_items
	set the_path to POSIX path of this_folder
	set date_cmd to "date '" & date_fmt & "'"
	set todays_folder to do shell script of date_cmd
	
	--	display dialog ((the number of added_items) as string) & " items added" --
	repeat with i from 1 to number of items in added_items
		set this_item to item i of added_items
		--display dialog the kind of (info for this_item) as string
		set item_kind to the kind of (info for this_item) as string
		if (item_kind is in ignore_kinds) then
			-- display dialog item_kind & " is being ignored"
		else
			
			set item_name to the name of (info for this_item)
			if (item_name is not equal to todays_folder) then
				--		display dialog "Name: " & item_name
				set make_folder_cmd to "/bin/test -d " & quoted form of (the_path & todays_folder) & " || /bin/mkdir  " & quoted form of (the_path & todays_folder)
				--display dialog make_folder_cmd
				do shell script make_folder_cmd
				set move_file_cmd to "/bin/test -d " & quoted form of (the_path & todays_folder) & " &&  /bin/mv -n " & quoted form of (the_path & item_name) & " " & quoted form of (the_path & todays_folder) & "/"
				--display dialog "Running: " & move_file_cmd
				do shell script move_file_cmd
				if (touch_file is true) then
					set touch_file_cmd to "/usr/bin/touch " & quoted form of (the_path & todays_folder & "/" & item_name)
					--display dialog "Running: " & touch_file_cmd
					do shell script touch_file_cmd
					
				end if
			else
				-- display dialog "Dated folder.. not running"
			end if
		end if
	end repeat
	if (open_folder is true) then
		if (bring_to_front is true) then
			tell application "Finder" to activate
		end if
		set the_folder to the_path & todays_folder
		set the_folder to POSIX file the_folder
		tell application "Finder" to open folder the_folder
	end if
	
end adding folder items to
PS: Das Script habe ich mal irgendwo gefunden.. (FolderOrg)
 
...

Hallo goegg-art,

mit der Finder Seitenleiste könnte ich mir so vorstellen:

Einen Smart Folder bzw. Saved Search "Aktuelle Downloads" mit einer Raw Query nach kMDItemFinderComment welcher Deine Ordneraktion an die gerade eben geladenen Dateien anfügt (und von den älteren Downloads wieder entfernt).

Allgemein wäre ich mit den Objekten in der Seitenleiste vorsichtig, was Löschen und Überschreiben angeht. Es wird nämlich das Original bearbeitet!
Ein Objekt in die Seitenleiste zu bekommen wäre auch nicht schwierig.
Lass es den Finder selectieren und über System Events und Finder process als keystroke "t" with command down einfügen...
Für ein sauberes Entfernen per AppleScript kenne ich keine Lösung.

Eine Lösung für das Dock und/oder die Titelleiste eines Finder Fensters wäre einen beliebigen Alias mit Namen "Aktuelle Downloads" zu verwenden dessen original item bearbeitet wird.
Ein möglicher Ablageort für diesen Alias wäre ~/Library/Favorites/ (wird möglicherweise erst erstellt wenn Du einen Favoriten anlegst shift-cmd-t)

Der Alias verbleibt also immer im Dock oder der Titelleiste und Deine Ordneraktion ändert nur den Pfad zum Original.

z.B:
Code:
tell application "Finder"
	set original item of alias file ((path to favorites folder as text) & "Aktuelle Downloads") to neuerPfad
end tell

Gruß Andi
 
Zurück
Oben Unten