• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Was gibt es Schöneres als den Mai draußen in der Natur mit allen Sinnen zu genießen? Lasst uns teilhaben an Euren Erlebnissen und macht mit beim Thema des Monats Da blüht uns was! ---> Klick

Spotlight Kommentare auslesen und ein Zeichen ersetzen

  • Ersteller Soul Monkey
  • 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 :)
 

space

Neuer Berner Rosenapfel
Registriert
02.12.05
Beiträge
1.949
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

Soul Monkey

Gast
Hallo space!

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

Gruss, Soul Monkey