property lepays : ""
property laligne : ""
property lechemin : ""
set monFichier to choose file with prompt "Sélectionnez le fichier listemail. txt à traiter"
set lechemin to choose folder with prompt "Sélectionnez le dossier pour la réception des fichiers texte par pays"
set monFichier to POSIX path of monFichier
set separ to {":", ";", ",", " ", " "}
set lextension to {"at", "ba", "be", "bg", "ca", "ch", "cl", "cz", "dk", "dz", "ee", "edu", "es", "eu", "fi", "fr", "uk", "gr", "hu", "ie", "il", "is", "it", "li", "lu", "mc", "nl", "pl", "pt", "se", "si", "va", "net", "org", "com"}
tell application "Finder"
set nb to do shell script "wc -l < " & monFichier
set ligne to 1
repeat
set commande to "sed -n '" & ligne & "p' " & monFichier
set laligne to do shell script commande
set AppleScript's text item delimiters to "@"
set suite to text item 2 of laligne -- récupère la ligne 1
set AppleScript's text item delimiters to ""
set suiteadresse to ""
set lecar to 1
repeat
if item lecar of suite is in separ then
set suiteadresse to suiteadresse as string
set lepays to text items (lepoint + 1) thru (lecar - 1) of suiteadresse
set lepays to lepays as string
if lepays is in lextension then my ecritligne()
exit repeat
else
set suiteadresse to suiteadresse & item lecar of suite
if item lecar of suite is "." then set lepoint to lecar
set lecar to lecar + 1
end if
end repeat
set ligne to ligne + 1
if ligne > nb then exit repeat
end repeat
end tell
tell application "Finder"
activate
(display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})
end tell
on ecritligne()
set ecritdans to lechemin as text
set ecritdans to ecritdans & lepays & ".txt"
set lelog to open for access (ecritdans) as text with write permission
write laligne & return to lelog starting at eof
close access lelog
end ecritligne