Bonjour,
J'aimerai juste renommer le fichier Datamatrix_.pdf en Datamatrix_022.pdf
Si la table SN à saisir est 022
Mon script final :
tell application "Finder"
    
    
    
set lechemin 
to choose folder with prompt "Sélectionnez le Dossier principal à traiter ?"
    
display dialog "Entrer le chiffre à ajouter à l'ISBN :" default answer ""
    
set lechiffre 
to text returned 
of result
    
set lecheminfichier 
to choose file with prompt "Sélectionnez le gabarits Indesign à copier ?"
    
set lecheminfichiercl 
to choose file with prompt "Sélectionnez le CL à copier ?"
    
display dialog "Entrer le numero de la table SN :" default answer ""
    
set ntablesn 
to text returned 
of result
    
display dialog "Entrer le numero d'édition :" default answer ""
    
set nedition 
to text returned 
of result
    
    
set ledossier 
to name 
of lechemin
    
set isbn 
to characters 1 
thru 3 
of ledossier & "-" & 
character 4 
of ledossier & "-" & 
characters 5 
thru 7 
of ledossier & "-" & 
characters 8 
thru 12 
of ledossier & "-" & lechiffre 
as text
    set lenomdossier 
to characters 13 
thru -4 
of ledossier 
as text
    
    repeat with i 
from 1 
to count lenomdossier
    
if item i 
of lenomdossier 
is " " 
then
    set lenomdossier 
to items 1 
thru (i - 1) 
of lenomdossier & "-" & 
items (i + 1) 
thru -1 
of lenomdossier
    
end if
    end repeat
    
    set lenomdossier 
to lenomdossier 
as text
    set lenomdossier 
to my remplace(lenomdossier)
    
set newnomledossier 
to isbn & (lenomdossier 
as text)
    
    
set sauv 
to AppleScript's text item delimiters
    
set AppleScript's text item delimiters 
to {":"}
    
set chem 
to lechemin 
as string
    set chemin 
to text items 1 
thru -3 
of chem 
as string
    set newchemin 
to chemin & ":" & newnomledossier
    
set AppleScript's text item delimiters 
to sauv
    
    
display dialog newnomledossier
    
    
make new 
folder at chemin with properties {name:newnomledossier}
    
make new 
folder at newchemin with properties {name:newnomledossier & "_fl1"}
    
make new 
folder at newchemin with properties {name:newnomledossier & "_fl2"}
    
make new 
folder at newchemin with properties {name:isbn & "
" & ntablesn & "" & nedition & "_fl3"}
    
make new 
folder at newchemin & ":" & newnomledossier & "_fl1" with properties {name:"corps-de-livre"}
    
make new 
folder at newchemin & ":" & newnomledossier & "_fl1" with properties {name:"couverture"}
    
make new 
folder at newchemin & ":" & newnomledossier & "_fl2" with properties {name:"corps-de-livre"}
    
make new 
folder at newchemin & ":" & newnomledossier & "_fl2" with properties {name:"couverture"}
    
    
    -- duplique les dossiers
    
set lesdossiers 
to folders of lechemin
    
set nb 
to count lesdossiers
    
    
repeat with i 
from 1 
to nb
    
duplicate item i 
of lesdossiers to newchemin & ":" & newnomledossier & "_fl1:couverture"
    
end repeat
    repeat with i 
from 1 
to nb
    
duplicate item i 
of lesdossiers to newchemin & ":" & newnomledossier & "_fl2:couverture"
    
end repeat
    --duplique les fichiers
    
set lesfichiers 
to files of lechemin
    
set nb 
to count lesfichiers
    
repeat with i 
from 1 
to nb
    
duplicate item i 
of lesfichiers to newchemin & ":" & newnomledossier & "_fl1:couverture"
    
end repeat
    repeat with i 
from 1 
to nb
    
duplicate item i 
of lesfichiers to newchemin & ":" & newnomledossier & "_fl2:couverture"
    
end repeat
    -- fin duplique
    
    
duplicate lecheminfichier to newchemin & ":" & newnomledossier & "_fl2:couverture"
    
duplicate lecheminfichiercl to newchemin & ":" & newnomledossier & "_fl1:corps-de-livre"
    
duplicate lecheminfichiercl to newchemin & ":" & newnomledossier & "_fl2:corps-de-livre"
    
    --duplique le fichier datamatrix
    
set ledatamatrix 
to "Macintosh HD:Utilisateurs:Socprest:Travaux en cours:NOUVEAUTES:GABARITS

ATAMATRIX

ATAMATRIX_.pdf"
    
duplicate ledatamatrix to newchemin
    --fin duplique datamatrix
    
    --efface fichier original
    
set ledossier 
to quoted form 
of POSIX path 
of lechemin
    
do shell script "rm -rf " & ledossier
end tell
on remplace(mavar)
    
set aremplacer 
to {39, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90}
    
set par 
to {45, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122}
    
set nbar 
to count aremplacer
    
set new 
to mavar
    
    -- remplace les caractères de la liste
    
set nb 
to count characters in new
    
set mavar 
to new
    
    
repeat with i 
from 1 
to nb
    
set a 
to character i 
in mavar
    
set lavaleur 
to ASCII number a
    
repeat with j 
from 1 
to nbar
    
if item j 
of aremplacer 
is lavaleur 
then
    set newcar 
to ASCII character (
item j 
of par)
    
if i = 1 
then
    set new 
to newcar & (
text 2 
thru nb 
of new)
    
set avant 
to ""
    
else
    set avant 
to text 1 
thru (i - 1) 
of new
    
end if
    if i = nb 
then
    set new 
to avant & newcar
    
else
    set new 
to avant & newcar & 
text nb 
thru -(nb - i) 
of mavar
    
end if
    end if
    end repeat
    end repeat
    set mavar 
to new
end remplace