[AS] inclure le nom du fichier dans le corps du fichier

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Yves Petronin
Date:  
À: applescript_fr
Sujet: [AS] inclure le nom du fichier dans le corps du fichier
Il y a cette routine apple qui ajoute un texte à la fin d'un fichier
(paramètre append_data true )

Si le texte doit être ajouté au début, c'est un peu plus compliqué...

Pour traiter le problème complet, il est probable que l'utilisation
d'un do shell script avec la commande "cat" soit bien plus puissante
que AS seul....Je suis à vrai dire trop débutant pour avoir un avis
catégorique..

--SCRIPT

set append_data to true

on write_to_file(this_data, target_file, append_data)
    try
        set the target_file to the target_file as text
        set the open_target_file to ¬
            open for access file target_file with write permission
        if append_data is false then ¬
            set eof of the open_target_file to 0
        write this_data to the open_target_file starting at eof
        close access the open_target_file
        return true
    on error
        try
            close access file target_file
        on error
        end try
        return false
    end try
end write_to_file


--SCRIPT

_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr