Ordneraktion - zip Files im Download ordner öffnen

tisco_over

Aktives Mitglied
Thread Starter
Registriert
06.12.2003
Beiträge
330
Reaktionspunkte
1
Hallo MacUser!

Ich hab mal wieder eine Applescript Problem. Ich würde gerne alle Zip Files die ich via Chrome downloade automatisch mit "The Unarchiver" öffnen.

So weit mein Odner-Skript:

Code:
on adding folder items to this_folder after receiving added_items
	try
		repeat with EachItem in added_items
			set ItemInfo to info for EachItem
			if not folder of ItemInfo then
				set FileExtensionOfItem to name extension of ItemInfo
				if FileExtensionOfItem is "zip" then
					tell application "The Unarchiver"
						process ZIP file at (POSIX path of EachItem)
					end tell
				end if
			end if
		end repeat
	end try
end adding folder items to

Leider erhalte ich die Fehlermeldung (Es wurde „Zeilenende“ erwartet, aber ein „Identifier“ wurde gefunden). Sagt mir als nicht-Applescripter gar nichts...

Kann mir bitte wer weiterhelfen?

Danke,
tisco
 
hier ein Lösung - da gefunden

Code:
on adding folder items to thisFolder after receiving added_items
	repeat with added_item in the added_items
		process_file(added_item)
	end repeat
end adding folder items to


on process_file(source_item)
	if is_Folder(source_item) then
		set folder_items to list folder source_item
		repeat with folder_item in folder_items
			set x to POSIX file (POSIX path of source_item & "/" & folder_item)
			process_file(x)
		end repeat
	else
		if is_zip(source_item) then
			extract_zip(source_item)
		end if
	end if
end process_file


on is_zip(source_file)
	set filename to POSIX path of source_file
	return (filename ends with ".zip")
end is_zip


on is_Folder(source_item)
	return (folder of (info for source_item))
end is_Folder


on extract_zip(zip_file)
	tell application "Finder"
		open zip_file
	end tell
end extract_zip
 
Für alle Interessierten. Ich habe das Skript nun erweitern - nun werden ZIP und RAR Dateien mittels Unarchiver geöffnet (es gibt auch die Option das die Datei gelöscht wird) und DMG Dateien mit dem Finder gemountet. Anschliessend wird dies mittels Growl bestätigt.

Es gibt sicherlich einfachere Wege dies zu lösen - dieser funktioniert aber für mich...

Code:
on adding folder items to thisFolder after receiving added_items
	repeat with added_item in the added_items
		process_file(added_item)
	end repeat
end adding folder items to


on process_file(source_item)
	if is_Folder(source_item) then
		set folder_items to list folder source_item
		repeat with folder_item in folder_items
			set x to POSIX file (POSIX path of source_item & "/" & folder_item)
			process_file(x)
		end repeat
	else
		--	zip Files...
		if is_zip(source_item) then
			extract_zip(source_item)
			tell application "GrowlHelperApp"
				set the allNotificationsList to ¬
					{"Ordneraktion"}
				
				set the defaultNotificationsList to ¬
					{"Ordneraktion"}
				
				register as application ¬
					"Growl AppleScript Sample" all notifications allNotificationsList ¬
					default notifications defaultNotificationsList ¬
					icon of application "The Unarchiver"
				
				--	Send a Notification...
				notify with name ¬
					"Ordneraktion" title ¬
					"Ordneraktion" description ¬
					"Zip-Archiv entpackt." application name "Growl AppleScript Sample"
			end tell
		end if
		--	rar Files...
		if is_rar(source_item) then
			extract_rar(source_item)
			
			tell application "GrowlHelperApp"
				set the allNotificationsList to ¬
					{"Ordneraktion"}
				
				set the defaultNotificationsList to ¬
					{"Ordneraktion"}
				
				register as application ¬
					"Growl AppleScript Sample" all notifications allNotificationsList ¬
					default notifications defaultNotificationsList ¬
					icon of application "The Unarchiver"
				
				--	Send a Notification...
				notify with name ¬
					"Ordneraktion" title ¬
					"Ordneraktion" description ¬
					"Rar-Archiv entpackt." application name "Growl AppleScript Sample"
			end tell
		end if
		--	dmg Files...
		if is_dmg(source_item) then
			extract_dmg(source_item)
			
			tell application "GrowlHelperApp"
				set the allNotificationsList to ¬
					{"Ordneraktion"}
				
				set the defaultNotificationsList to ¬
					{"Ordneraktion"}
				
				register as application ¬
					"Growl AppleScript Sample" all notifications allNotificationsList ¬
					default notifications defaultNotificationsList ¬
					icon of application "Finder"
				
				--	Send a Notification...
				notify with name ¬
					"Ordneraktion" title ¬
					"DMG Aktion" description ¬
					"DMG Datei geöffnet." application name "Growl AppleScript Sample"
			end tell
		end if
		
	end if
end process_file

--	zip Files...
on is_zip(source_file)
	set filename to POSIX path of source_file
	return (filename ends with ".zip")
end is_zip

on extract_zip(zip_file)
	tell application "The Unarchiver"
		open zip_file
	end tell
end extract_zip
--	zip Files...

--	rar Files...
on is_rar(source_file)
	set filename to POSIX path of source_file
	return (filename ends with ".rar")
end is_rar

on extract_rar(rar_file)
	tell application "The Unarchiver"
		open rar_file
	end tell
end extract_rar
--	rar Files...

--	dmg Files...
on is_dmg(source_file)
	set filename to POSIX path of source_file
	return (filename ends with ".dmg")
end is_dmg

on extract_dmg(dmg_file)
	tell application "Finder"
		open dmg_file
	end tell
end extract_dmg
--	rar Files...


on is_Folder(source_item)
	return (folder of (info for source_item))
end is_Folder
 
Zurück
Oben Unten