--recherche doubles dans un dossier y compris les sous dossier
tell application "Finder"
set Chemin to choose folder with prompt "Sélectionnez le dossier contenant les fichiers à redater"
my inspecter(Chemin)
end tell
on inspecter(Chemin)
tell application "Finder"
set Chemin to Chemin as string
set repertoire to quoted form of POSIX path of Chemin as string
set laliste to do shell script "cksum " & repertoire & "/* | sort"
set nb to count paragraph of laliste
repeat with i from 1 to nb
set x to paragraph i of laliste
--crée un fichier provisoire avec la list au format mac (CR+LF)
set aa to ASCII character 10
set lelog to open for access ((path to desktop folder as text) & "prov.txt") as text with write permission
write x & aa to lelog starting at eof
close access lelog
end repeat
-- traitement des dossiers :
set Chemin to Chemin as alias
set les_dossiers to folders of Chemin
repeat with chaque_dossier in les_dossiers
my inspecter(chaque_dossier)
end repeat
end tell
end inspecter
-- faire le tri du fichier prov et tester
set Chemin to ((path to desktop folder as text) & "prov.txt") as string
set repertoire to quoted form of POSIX path of Chemin
set laliste to do shell script "sort " & repertoire
set nb to count paragraph of laliste
repeat with i from 1 to nb - 1
set x to paragraph i of laliste
set xx to characters 1 thru 17 of x as string
set y to paragraph (i + 1) of laliste
set yy to characters 1 thru 17 of y as string
if xx = yy then
set x to characters (offset of "/" in x) thru end of x as string
set y to characters (offset of "/" in y) thru end of y as string
--cree le fichier double
set lelog to open for access ((path to desktop folder as text) & "les doubles.txt") as text with write permission
write "DOUBLE : " & x & " AVEC " & y & return to lelog starting at eof
close access lelog
end if
end repeat
--efface le fichier provisoire
set aeffacer to quoted form of POSIX path of ((path to desktop folder as text) & "prov.txt")
do shell script "rm " & aeffacer
tell application "Finder"
(display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})
end tell