AppleScript: Prüfen ob Text enthalten ist, funktioniert nicht

S

Series 60

Aktives Mitglied
Thread Starter
Dabei seit
31.12.2005
Beiträge
328
Reaktionspunkte
7
Hallo

Ich möchte per AppleScript prüfen, ob bestimmter Text in einem Text-File vorhanden ist. Ich habe bereits einen ersten Ansatz, doch leider funktioniert es nicht. Kann mir jemand sagen was ich falsch gemacht habe?

set stringContainsName to false
set tString to "test"
set tNames to "/Users/Philipp/Desktop/test.txt"
repeat with aName in paragraphs of tNames
if aName is in tString then set stringContainsName to true
end repeat
if stringContainsName then
display dialog "enthalten"
else
display dialog "nicht enthalten"
end if



Vielen Dank
Philipp
 
set stringContainsName to false
set tString to "test"
set tFile to POSIX path of ":Users:philipp:Desktop:test.txt" as string
-- Alternativ:
-- set tFile to choose file with prompt "Textdatei wählen"

set tNames to read tFile
if tString is in tNames then set stringContainsName to true

if stringContainsName then
display dialog "enthalten"
else
display dialog "nicht enthalten"
end if
 
Vielen Dank madu, funktioniert perfekt!
 
Zurück
Oben Unten