[AS] Ajouter un pr éfixe à une liste de fichiers

Page principale
Supprimer ce message
Répondre à ce message
Auteur: PJ
Date:  
À: applescript_fr
Sujet: [AS] Ajouter un pr éfixe à une liste de fichiers
on open liste_des_fichiers
--
-- Initialiser les constantes
--
set label_Annuler to "Annuler"
set label_Continuer to "Continuer"
set label_Reprendre to "Reprendre"
--
-- Initialiser les variables de travail
--
set racine_ok to false as boolean

tell application "Finder"
set nb_fichiers to the count items in liste_des_fichiers
end tell
--
-- Saisir un préfixe pour renommer l'ensemble des fichiers
--
set message_utilisateur to "Entrez un préfixe qui sera ajouté au nom des
fichiers sélectionnés"
repeat
set reponse_utilisateur to display dialog message_utilisateur ¬
buttons {label_Continuer, label_Annuler} default button 1 ¬
with icon note default answer ""
set racine_saisie to text returned of reponse_utilisateur
set bouton_choisi to button returned of reponse_utilisateur
if length of racine_saisie > 0 then
if bouton_choisi = label_Continuer then
set racine_ok to true
exit repeat -- Saisie du préfixe
end if
else
if bouton_choisi = label_Continuer then
set message_utilisateur to "Aucune information saisie !"
end if
end if
end repeat -- Saisie du préfixe
--
-- Renommer les fichiers sélectionnés
--
tell application "Finder"
repeat with un_fichier in liste_des_fichiers
get the info for the un_fichier
set useMe to the result
get the name of useMe
set ancien_nom to the result
-- display dialog ancien_nom
set nouveau_nom to racine_saisie & ancien_nom
-- display dialog nouveau_nom
set the name of un_fichier to nouveau_nom
end repeat
end tell
end open
_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr