Re: [AS] Un script pour renommer un fichier

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Yvan KOENIG via Applescript_fr
Date:  
À: Liste AppleScript francophone
CC: Yvan KOENIG
Sujet: Re: [AS] Un script pour renommer un fichier
--on open fileName -- vérification de la nature du paramètre
set fileName to "SSD 1000:Users:**********:Desktop:koenig.pdf" as alias
if class of fileName is list then set fileName to first item of fileName
set filePath to fileName as text -- retourne le chemin d'accès Hfs
tell application "Finder"
    set theFileName to name of fileName --> "koenig.pdf"
    set theFilePath to fileName as string --> "SSD 1000:Users:**********:Desktop:koenig.pdf"
    --set extens to fileName -- recupere l'extension du fichier
    set lextension to name extension of fileName --> "pdf"
    set nom_court to text 1 thru ((length of theFileName) - (1 + (length of lextension))) of theFileName --> "koenig"
    set folderPath to folder of fileName as alias --> alias "SSD 1000:Users:**********:Desktop:"
    set folderName to name of folderPath --> "Desktop"
end tell -- "Finder"
(* 
-- Ces instructions désormais inutiles n'avaient AUCUNE raison de figurer dans un bloc tell "Finder"
        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 theFileName
        set nomcourt to (items 1 thru -2 of elements) as string
        -- set ancien_nom to nomcourt -- nom sans extension
        set AppleScript's text item delimiters to sauv --restaurer la variable delimiteur
        *)
--end open


Yvan KOENIG (VALLAURIS, France) jeudi 6 mai 2021 17:35:55
_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr