Bonjour,
Pour analyser il me faudrait plus d'élément sur l'erreur que tu observes.
Lors de l'erreur, quelle ligne est surlignée dans le script et y a t'il un fichier "les erreurs.txt" qui s'est créé sur le bureau?
Autre question as-tu bien installé le logiciel "exiftool"
Edit: Exiftool à télécharger là : https://exiftool.org/
-- remplace date du fichier par la date exif creation et renomme les fichiers avec la date de création
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(un_dossier)
tell application "Finder"
-- traitement des fichiers :
set les_fichiers to files of un_dossier
repeat with chaque_fichier in les_fichiers
-- traitement d'un fichier
set lefichier to chaque_fichier
set AppleScript's text item delimiters to {""}
set nom to name of chaque_fichier --récupère le nom du fichier
set extens to document file nom in un_dossier --recupere l extension du fichier
set lextension to name extension of extens
set sauv to AppleScript's text item delimiters --sauvegarder la variable delimiteur
set AppleScript's text item delimiters to {"."} --récupère la partie avant le dernier "."
set elements to text items of nom
set nomcourt to (items 1 thru -2 of elements) as string
set ancien_nom to nomcourt
set AppleScript's text item delimiters to sauv --restaurer la variable delimiteur
set chaque_fichier to chaque_fichier as string
try
set datephoto to do shell script "/usr/local/bin/exiftool -DateTimeOriginal " & quoted form of POSIX path of chaque_fichier
if datephoto is "" then set datephoto to do shell script "/usr/local/bin/exiftool -CreationDate " & quoted form of POSIX path of chaque_fichier
if datephoto is "" then set datephoto to do shell script "/usr/local/bin/exiftool -CreateDate " & quoted form of POSIX path of chaque_fichier
on error
-- Ecrit un fichier erreur sur le bureau si erreur chargement date
set lelog to open for access ((path to desktop folder as text) & "les erreurs.txt") as text with write permission
write "Le fichier ne contient pas de date : " & chaque_fichier & return to lelog starting at eof
close access lelog
set datephoto to ""
end try
if length of datephoto > 20 then
set x to (length of datephoto) - 33
set DateOriginale to text -x thru -1 of datephoto
set ladate to text 1 thru 5 of DateOriginale
set lannee to ladate
set ladate to ladate & text 7 thru 8 of DateOriginale
set lemois to text 7 thru 8 of DateOriginale
set ladate to ladate & text 10 thru 11 of DateOriginale
set lejour to text 10 thru 11 of DateOriginale
set ladate to ladate & text 13 thru 14 of DateOriginale
set lheure to text 13 thru 14 of DateOriginale
set ladate to ladate & text 16 thru 17 of DateOriginale
set lesminutes to text 16 thru 17 of DateOriginale
set ladate to ladate & "." & text 19 thru 20 of DateOriginale
set lessecondes to text 19 thru 20 of DateOriginale
set newnom to lannee & "-" & lemois & "-" & lejour & " " & lheure & "." & lesminutes & "." & lessecondes
set xxx to ladate as string
if xxx is " 000000000000.00" then
-- Ecrit un fichier erreur sur le bureau si erreur chargement date(=0000...)
set lelog to open for access ((path to desktop folder as text) & "les erreurs.txt") as text with write permission
write "Le fichier ne contient pas de date : " & chaque_fichier & return to lelog starting at eof
close access lelog
else
do shell script "touch -t " & ladate & " " & quoted form of POSIX path of chaque_fichier
end if
end if
if datephoto is not "" then
set aa to container of lefichier as string
set numero to 1
set lenewnom to newnom
repeat
if exists aa & lenewnom & "." & lextension then
set lenewnom to newnom & "(" & numero & ")"
set numero to numero + 1
else
set newnom to lenewnom
exit repeat
end if
end repeat
set name of lefichier to newnom & "." & lextension
else
set lelog to open for access ((path to desktop folder as text) & "les erreurs.txt") as text with write permission
write "Le fichier ne contient pas de date : " & chaque_fichier & return to lelog starting at eof
close access lelog
end if
end repeat
-- traitement des dossiers :
set les_dossiers to folders of un_dossier
repeat with chaque_dossier in les_dossiers
-- traitement d'un dossier
my inspecter(chaque_dossier)
end repeat
end tell
end inspecter
tell application "Finder"
(display dialog ("waouou ... Ca y est c'est fait !") buttons {"Salut !"})
end tell
cksum nom_du_fichier
cksum repertoire/* | sort
--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 - 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 lelog to open for access ((path to desktop folder as text) & "les doubles.txt") as text with write permission
write "En double : " & x & " avec " & y & return to lelog starting at eof
close access lelog
end if
--creer un txt provisoire avec les fichiers cheké
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
-- ecrit le dernier fichier du dossier
set lelog to open for access ((path to desktop folder as text) & "prov.txt") as text with write permission
write y & aa to lelog starting at eof
close access lelog
-- 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
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
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
--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 - 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 lelog to open for access ((path to desktop folder as text) & "les doubles.txt") as text with write permission
write "En double : " & x & " avec " & y & return to lelog starting at eof
close access lelog
end if
--creer un txt provisoire avec les fichiers cheké
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
-- ecrit le dernier fichier du dossier
if nb > 1 then
set lelog to open for access ((path to desktop folder as text) & "prov.txt") as text with write permission
write y & aa to lelog starting at eof
close access lelog
end if
-- 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
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
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
--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
if nb = 1 then
set x to paragraph 1 of laliste
set xx to characters 1 thru 17 of x as string
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 if
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 lelog to open for access ((path to desktop folder as text) & "les doubles.txt") as text with write permission
write "En double : " & x & " avec " & y & return to lelog starting at eof
close access lelog
end if
--creer un txt provisoire avec les fichiers cheké
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
-- ecrit le dernier fichier du dossier
if nb > 1 then
set lelog to open for access ((path to desktop folder as text) & "prov.txt") as text with write permission
write y & aa to lelog starting at eof
close access lelog
end if
-- 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
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
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
--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