2017-11-13 1 views
0

Ich versuche, ein Apple-Skript zu schreiben, das die unbeaufsichtigten TVShows erhält und den Dateinamen (vorzugsweise ohne den vollständigen Pfad, nur "whatever.m4v") in einer Textdatei. HierApplescript Ergebnisse zu txt-Datei

ist der Code, den ich habe:

tell application "iTunes" 
    set watchedEpisodes to tracks of playlist "TV Shows" whose unplayed is false and played count > 0 
    set unwatchedEpisodes to tracks of playlist "TV Shows" whose unplayed is true 
    if (count unwatchedEpisodes) > 0 then 
     set trackNames to {} 
     repeat with anEpisode in unwatchedEpisodes 
      set end of trackNames to ((name of anEpisode) as text) & " of show " & show of anEpisode & " Filename: " & location of anEpisode 
     end repeat 

     set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return} 

     set unwatchedTVShows to trackNames as text 
     do shell script "echo " & unwatchedTVShows & " > /Volumes/Data/Media/Kodi/unwatchedTVShows.txt" 

     #display dialog trackNames as text 

     set AppleScript's text item delimiters to TID 
    end if 
end tell 

ich die folgende Fehlermeldung erhalten:

error "iTunes got an error: sh: -c: line 0: unexpected EOF while looking for matching `'' 
sh: -c: line 1: syntax error: unexpected end of file" number 2 

Wenn ich die "unwatchedTVShows" varible in der Shell-Anweisung ersetzen wie folgt aus:

do shell script "echo " & "test" & " > /Volumes/Data/Media/Kodi/unwatchedTVShows.txt" 

es funktioniert wie ich es erwarte (ich habe einen Dateinamen namens "unwatchedTVShows.txt" und es enthält das Wort "te st ". Ich kann die "Display dialog trackNames as text" Zeile verwenden, die ich momentan kommentiert habe und es funktioniert gut. Was vermisse ich?

Antwort

0

Die Liste der Shows enthält Anführungszeichen und Leerzeichen. Entkommen Sie einfach der ganzen Liste mit quoted form of:

do shell script "echo " & quoted form of unwatchedTVShows & " > /Volumes/Data/Media/Kodi/unwatchedTVShows.txt" 
+0

Perfekt. Vielen Dank!! – Brian