--GetNameSong7a - avec les 2 boucles fonctionnelles
set UserName to "FRANCOISBOUDREAU"
set FolderName to "dossier sans titre"
-- Ouvre les applications requises au fonctionnement
tell application "Finder" to open file "FM_MUSIQUE"
-- Ouverture du répertoire principal
tell application "Finder"
activate
open folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
-- Obtenir le nombre d'artistes (sous-répertoires) du répertoire principal
set DirCount to count folders of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
set d to 1
end tell
-- Boucle principale - pour chacun des artistes - SubFolderName = l'artiste
repeat until d > DirCount
tell application "Finder"
activate
set SubFolderName to name of folder d of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
-- Ouvrir le sous-répertoire
open folder SubFolderName of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
-- Obtenir le nombre de documents du répertoire de l'artiste
set DocCount to count files of folder SubFolderName of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
set i to 1
set DocName to name of first file of folder SubFolderName of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
-- pour supprimer l'extension du fichier (.htm)
set CharCount to count every character of DocName
set DocName to characters 1 thru {CharCount - 4} of DocName
set DocName to DocName as text
end tell
-- Boucle secondaire pour extraire le data de chacun des documents
repeat until i > DocCount
tell application "Finder"
activate
set DocName to name of file i of folder SubFolderName of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
end tell
tell application "Finder" to open file i of folder SubFolderName of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk
-- Obtenir les données du document Safari : Artiste, titre, auteur et paroles
tell application "Safari"
activate
set Artiste to first paragraph of text of document 1 -- extrait le nom de l'artiste uniquement
set Titre to second paragraph of text of document 1 -- extrait le titre de la chanson uniquement
set Auteur to third paragraph of text of document 1 -- extrait l'auteur de la chanson uniquement
set parcount to count every paragraph of text of document 1
set Paroles to paragraphs 5 thru {parcount - 3} of text of document 1 -- extrait les paroles uniquement
end tell
-- Pour corriger texte de Safari
tell application "AppleWorks 6"
-- make a new document of type text
activate
make new document at front with properties {document kind:text document} with data Paroles
set Paroles to text of document 1
close window saving no -- works the same with front window or file
end tell
-- Activation de FileMaker Pro et passer paramètres pour recherche et collage des paroles
tell application "FileMaker Pro"
activate
set field "gArtiste" of current record to Artiste -- replace "texte"
set field "gTitre" of current record to Titre -- replace "texte"
set field "gAuteur" of current record to Auteur -- replace "texte"
set field "gParoles" of current record to Paroles -- replace "texte"
-- faire exécuter FileMaker script: "Recherche chanson et colle paroles"
do script "Recherche chanson et colle parole"
end tell
-- Ré-active Safari et ferme la fenêtre active
tell application "Safari"
activate
close front window
end tell
-- change la couleur du document une fois le processus terminé
tell application "Finder" to set label index of file i of folder SubFolderName of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk to 6 -- bleu
-- Pour activer le prochain document de la série
set i to i + 1
tell application "Finder"
activate
end tell
end repeat
-- change la couleur de la chemise une fois le processus terminé
tell application "Finder" to set label index of folder d of folder FolderName of folder "Desktop" of folder UserName of folder "Users" of startup disk to 2 -- rouge
-- passe au prochain artiste
set d to d + 1
tell application "Finder"
activate
close front window
end tell
end repeat
Hope this can help some people through new Script
Sincerely yours
François