• Wieder einmal haben uns unsere Apfeltalker tolle Fotos zur Abstimmung eingesandt. Welches ist Euer Favorit? Stimmt mit ab! Hier geht es zur Abstimmung --> Klick
  • Es ist bereits Apfeltalk-Tradition und wir möchten sie auch in diesem Jahr fortsetzen: Unser Apfeltalk-Weihnachtslogo-Wettbewerb hat begonnen! Gestaltet für uns das Weihnachtsbanner, das im Monat Dezember bis zum Weihnachtsfest unsere Webseite schmücken soll. Lasst Eurer Kreativität freien Lauf! Hier geht es zum Wettbewerb --> Klick

Spotlight Kommentare auslesen und ein Zeichen ersetzen

  • Ersteller Ersteller Soul Monkey
  • Erstellt am Erstellt am

Soul Monkey

Gast
Hallo, ich braeuchte ein AppleScript das die aktuelle Auswahl im Finder abfraegt und dann nach der Reihe die Dateien durchgeht, deren Spotlight Kommentar abfraegt und dann ein Zeichen "&" durch "|" ersetzt (derzeit sehen die Spotlight Kommentare einer Datei so aus "&tag1 &tag2 &tag3 &tag4") und den Kommentar wieder schreibt.

Ein solches Skript konnte ich nicht finden und selbst bekomme ich das nicht hin. Ein Skript das die Moeglichkeit bietet neue Spotlight Kommentare hinzuzufuegen bzw. die alten mit den neuen zu ueberschreiben gibt es zum Beispiel hier.
http://bbs.applescript.net/viewtopic.php?id=14199

Bisher habe ich

Code:
tell application "Finder"
	repeat with i in (get selection)
		--set comment of i to ""
		--hier fehlt der mittelteil
	end repeat
end tell

bei tausenden von Dateien dauert die manuelle Bearbeitung bzw. loeschen und neu zuweisen laaaaaange.

Danke :-)
 
Hi Soul Monkey!

Habe mich auf Grund deines Posts mal mit AppleScript's text item delimiters befasst und mich etwas eingefriemelt…



Code:
tell application "Finder"
	activate
	set sel to selection
	repeat with i from 1 to count of items of sel
		set thisFile to (item i of sel)
		repeat with thisFile in sel
			tell thisFile
				set spotText to comment as text
			end tell
		end repeat
	end repeat
end tell




set findThis to "&"
set replaceWith to "|"

set newText to switchSign of spotText from findThis to replaceWith


tell application "Finder"
	repeat with i from 1 to count of items of sel
		set thisFile to (item i of sel)
		set comment of thisFile to newText
	end repeat
end tell

to switchSign of theText from SearchString to ReplaceString
	set OldDelims to AppleScript's AppleScript's text item delimiters
	set AppleScript's AppleScript's text item delimiters to SearchString
	set newText to text items of theText
	set AppleScript's AppleScript's text item delimiters to ReplaceString
	set newText to newText as text
	set AppleScript's AppleScript's text item delimiters to OldDelims
	return newText
end switchSign

Gruss
 
  • Like
Reaktionen: 1 Person
Hallo space!

Vielen Dank fuer das Script, funktioniert wunderbar, da kann ich gleich wieder aufhoeren das manuell zu machen.

Gruss, Soul Monkey