I have a Text File like this:
Listing Leenbakker Jobs maandag, 24 augustus 2009 12:01:57
36744 voordeelbonnen eindhoven
36749_leenbakker sollicitatie
36888_leenbakker
37067_koofstreamer
37068_LB streamer kerst
How can I skip empty paragraphs or paragraphs containing "Listing " in one run?
sset thefile to (choose file with prompt "Kies het bestand: JobList.txt")
tell application "Finder" to set filename to (name of thefile)
if filename is not "JobList.txt" then
display dialog "Niet het juiste bestand gekozen!" buttons {"Cancel"} default button 1
quit
else
tell application "System Events"
set isRunning to ((application processes whose (name is equal to "TextEdit")) count)
end tell
if isRunning is greater than 0 then
tell application "TextEdit" to quit
end if
do shell script "defaults write com.apple.TextEdit RichText -bool No"
set textToBeEdited to read thefile
set master_list to {}
repeat with i from 1 to (count of paragraphs of textToBeEdited)
set theText to paragraph i of textToBeEdited
display dialog "Welke actie voor: " & theText buttons {"Skip", "Weg", "Naar Archief"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Naar Archief" then
display dialog theText & "\ntijdelijk (3mnd) of permanent archiveren?" buttons {"Tijdelijk", "Permanent"} default button 2
if the button returned of the result is "Permanent" then
copy paragraph i of textToBeEdited & " p" to end of master_list
else
copy paragraph i of textToBeEdited & " t" to end of master_list
end if
else
if the button_pressed is "Weg" then
copy paragraph i of textToBeEdited & " w" to end of master_list
else
""
end if
end if
end repeat
tell application "TextEdit"
activate
close every document saving no
make new document
set the name of window 1 to "Archive Info"
set currentText to text of front document
set newText to currentText & return & (current date) & return
set text of front document to newText
end tell
repeat with this_master_item in master_list
tell application "TextEdit"
set currentText to text of front document
set newText to currentText & return & this_master_item
set text of front document to newText
end tell
end repeat
end if
tell application "TextEdit" to save front document in (path to desktop as string) & "JobList_Archive.txt" with replacing
tell application "TextEdit" to quit
display dialog "De Job lijst is bewaard op het Bureaublad\nBekijken?" buttons {"Nee", "Ja"} default button 2
if the button returned of the result is "Nee" then
quit
else
tell application "TextEdit"
open (path to desktop as string) & "JobList_Archive.txt"
end tell
end if
–Peter–