A
Appleyou
Mitglied
Thread Starter
- Dabei seit
- 07.03.2015
- Beiträge
- 29
- Reaktionspunkte
- 0
Hallo ich möchte gerne mit Applescript in eine txt Datei schreiben dfür habe ich schon ein Script.
jetzt möchte ich meinen text mit dem Applscript nicht einfach hinter den Text in der Text Datei schreiben sondern nur zum bsp. in Zeile 5 oder 20...
ich hoffe mir kann dabei jemand helfen.
LG Yannick
Code:
-- Text abfragen
set thee to display dialog "Legen sie den text an." default answer "" buttons {"OK"} default button 1
set theText to text returned of thee
-- Dateipfad festlegen
set dateiPfad to (path to desktop as string) & "testtext.txt"
-- Text in Datei schreiben
writeToFile(theText, dateiPfad, true)
-- Handler, um Texte in Dateien zu schreiben.
-- boolAppend = true: Text an vorhandene Datei anhängen
-- boolAppend = false: Text in Datei überschreiben
on writeToFile(theText, theFile, boolAppend)
-- ljr (applescript.bratis-lover.net/library/file/)
local theText, theFile, boolAppend, otf
try
set theFile to theFile as string
set otf to open for access file theFile with write permission
if boolAppend is false then set eof of otf to 0
write theText to otf starting at eof
close access otf
on error eMsg number eNum
try
close access file otf
end try
error "Can't writeToFile: " & eMsg number eNum
end try
end writeToFile
ich hoffe mir kann dabei jemand helfen.
LG Yannick
Zuletzt bearbeitet: