TextEdit "scripten"

G

Gomiaf

Hallo Ihr!

Ist es möglich, mit AppleScript eine bestimmte Text-Datei in TextEdit zu öffnen, an eine bestimmte Stelle zu hüpfen, ein paar Zeilen einzufügen und das ganze wieder abzuspeichern?

Ich habe mich im Netz schon dämlich gesucht.

Viele Grüße

Gomiaf
 
...

Hallo Gomiaf,

Textdateien kannst Du direkt mit Apple Script bearbeiten. Text Edit ist nicht nötig.

Gruß Andi
 
Aha, und wie geht das? Hast Du evtl. einen Link parat?

Viele Grüße

Gomiaf

P.S.: Schön, Dich mal wieder zu lesen.
 
...

Hallo Gomiaf,

ein kleines Beispiel:

set the_file to (((path to desktop) as string) & "test.txt") as file specification

set record_1 to {record_name:"Record A", record_value:{"This", "is", "a", "list.", 1, 2, 3}}
set record_2 to {record_name:"Record B", record_value:"A string."}
set record_3 to {record_name:"Record C", record_value:1.0 as real}
set the_data to {record_1, record_2, record_3}

try
open for access the_file with write permission
set eof of the_file to 0
write (the_data) to the_file starting at eof as list
close access the_file
on error
try
close access the_file
end try
end try

set read_data to read the_file as list

Gruß Andi
 
Aaaaaah, super, genauso so ein Sample suchte ich. Vielen Dank. :)
 
Zurück
Oben Unten