Ho provato a creare un AppleScript che legge un file di testo e inserisce il contenuto in un elenco. Il file è un semplice file di testo in cui ogni riga è simile a questa: example-"example"
Leggi file di testo in elenco in Applescript
Il primo è un nome file e l'altro è un nome di cartella.
Ecco il mio codice ora:
set listOfShows to {}
set theFile to readFile("/Users/anders/Desktop/test.txt")
set Shows to read theFile using delimiter return
repeat with nextLine in Shows
if length of nextLine is greater than 0 then
copy nextLine to the end of listOfShows
end if
end repeat
choose from list listOfShows
on readFile(unixPath)
set foo to (open for access (POSIX file unixPath))
set txt to (read foo for (get eof foo))
close access foo
return txt
end readFile
Quando eseguo che l'uscita ottengo questo:
error "Can not change \"Game.of.Thrones-\\\"Game Of \" to type file." number -1700 from "Game.of.Thrones-\"Game Of " to file"
Mia lista simile a questa: Game.of.Thrones- "Game of Thrones "e altre due righe come questa.
Si legge ancora solo "Game .of.Thrones - \ "Game Of" nella mia uscita, non ho alcun errore ora. – andeersg
Ho provato con il testo: 1text, 2text ... 5text nel file di testo ora. Il risultato è 1text, 2text, 3text , 4text, 5. Not 5text – andeersg
Lo script recupera ogni riga del file (separata da un carattere di nuova riga come un ritorno) e la inserisce in una lista - non è a cosa hai chiesto? Non sei sicuro del motivo per cui il file non verrà letto completamente, a meno che tu non stia usando un comando di lettura normale e stai giocando con i delimitatori o il numero di caratteri letti. –