tell application "Finder"
set cheminsource to choose folder with prompt "Sélectionnez le dossier contenant les fichiers à copier"
set chemincible to choose folder with prompt "Sélectionnez le dossier cible"
set laliste to choose file with prompt "Sélectionnez le fichier liste"
my inspecter(cheminsource, chemincible, laliste)
end tell
on inspecter(source, cible, liste1)
set dossiersource to source as string
set dossiercible to cible as string
set destination to dossiercible
open for access liste1
read liste1
set tout_le_fichier to the result
close access liste1
set AppleScript's text item delimiters to (ASCII character 13)
set toutes_les_lignes to (every text item of tout_le_fichier) as list
set AppleScript's text item delimiters to ""
set tout_le_fichier to ""
set nouveaudossier to 0 as integer
set atraiter to 0 as integer
repeat with une_ligne in toutes_les_lignes
set letest to une_ligne as string
if nouveaudossier = 1 then
set dossiercible to dossiercible as string
set ledossier to une_ligne as string
tell application "Finder"
make new folder at dossiercible with properties {name:ledossier}
end tell
set nouveaudossier to 0
set destination to dossiercible & ledossier
end if
if letest = "$" then
set nouveaudossier to 1
set atraiter to 2
end if
if atraiter > 0 then
set atraiter to atraiter - 1
else
try
tell application "Finder"
set lefichier to do shell script "find " & quoted form of POSIX path of dossiersource & " -iname " & une_ligne
set CheminImage to POSIX file lefichier as string
duplicate CheminImage to destination
end tell
on error
set lelog to open for access (path to desktop folder as text) & "lelog.txt" as text with write permission -- ouvre le fichier log et ecritles valeur séparé par une tabulation
write "Le fichier " & une_ligne & " N'a pas été trouvé" & return to lelog starting at eof
close access lelog -- ferme le fichier log
end try
end if
end repeat
end inspecter
tell application "Finder"
(display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})
end tell