Bonjour,
J'ai essayé ce script
--[SCRIPT]
set dossierSource to "Disque_2:prix_revendeur"
tell application "System Events"
make new file at end of folder dossierSource with properties
{name:"la_totale.txt"}
end tell
set nouveau to dossierSource & "la_totale.txt" as alias
repeat with i from 1 to 1366
set source to text -5 thru -1 of ("00000" & i) & ".txt"
write (return & source & return) to file (dossierSource & source)
starting at eof
set textI to read file (dossierSource & source)
write textI to nouveau starting at eof
end repeat
--[/SCRIPT]
Toutefois le script s'arrete à la création du fichier "la_totale.txt" ?
Ce fichier reste vide
Roland
___________________________________________________________________
Contact
<bena.bena@???>
Telephone
+33 (0)5 56 63 59 07 et +33 (0)6 71 28 40 45
Fax
+33 (0)5 17 47 53 48
Adresse
7 lieu dit Labrouche
33210 Saint Pardon de Conques - France
Le 3 juin 09 à 12:00, applescript_fr-request@??? a écrit :
> Envoyez vos messages pour la liste Applescript_fr à
> applescript_fr@???
>
> Pour vous (dés)abonner par le web, consultez
> http://listes.patpro.net/mailman/listinfo/applescript_fr
>
> ou, par email, envoyez un message avec 'help' dans le corps ou dans le
> sujet à
> applescript_fr-request@???
>
> Vous pouvez contacter l'administrateur de la liste à l'adresse
> applescript_fr-owner@???
>
> Si vous répondez, n'oubliez pas de changer l'objet du message afin
> qu'il soit plus spécifique que "Re: Contenu du digest de
> Applescript_fr..."
>
> ---------------------------------------------------------------------------------------
> Orange vous informe que cet e-mail a ete controle par l'anti-virus
> mail.
> Aucun virus connu a ce jour par nos services n'a ete detecte.
>
>
> Thèmes du jour :
>
> 1. Re: inclure le nom du fichier dans le corps du fichier
> (Serge Ségu)
> 2. Fwd: Rép: inclure le nom du fichier dans le corps du fichier
> (Yvan KOENIG)
> 3. inclure le nom du fichier dans le corps du fichier (Yves
> Petronin)
> 4. inclure le nom du fichier dans le corps du fichier (Yves
> Petronin)
>
> De : Serge Ségu <serge.segu@???>
> Date : 2 juin 2009 13:31:51 HAEC
> À : La liste AppleScript Francophone <applescript_fr@???>
> Objet : Rép : [AS] inclure le nom du fichier dans le corps du fichier
> Répondre à : La liste AppleScript Francophone <applescript_fr@???
> >
>
>
>
> Le 2 juin 09 à 10:00, Roland Bena a écrit :
>
>> Je ne trouve pas comment entrer le nom du fichier dans le texte.
>
> Avec la commande WRITE. Regarde le dictionnaire AppleScript
> Barre de menus de l'Editeur de Scripts : Fenetre > bibliotheque >
> standardAdditions > File Read/Write
>
> un exemple de routine ci-dessous
>
> writeFile("nom du ficher", chemin d'acces du fichier, true)
>
> -- Write data to a file; parameter: text, filePath, boolean [false:
> overwrite the file]
> on writeFile(theText, thePath, appendData)
> try
> set thePath to thePath as string
> set idFile to open for access file thePath with write permission
> if appendData is false then set eof of the idFile to 0
> write theText to idFile starting at eof
> close access id_file
> on error
> close access file thePath
> return false
> end try
> end writeFile
>
> Serge
> --
> http://macscripting.blogspot.com
>
>
>
>
>
>
>
>
>
>
>
>
>
> De : Yvan KOENIG <koenig.yvan@???>
> Date : 2 juin 2009 14:49:21 HAEC
> À : La liste AppleScript Francophone <applescript_fr@???>
> Objet : [AS] Fwd: Rép: inclure le nom du fichier dans le corps du
> fichier
> Répondre à : La liste AppleScript Francophone <applescript_fr@???
> >
>
>
> Après diverses péripéties ce message posté
> 2 juin 2009 11:57:28 HAEC
> parvient enfin à passer ;-)
>
>
> Le 2 juin 2009 à 10:00, Roland Bena a écrit :
>
>> Bonjour,
>>
>> J'ai 1600 petits fichiers au format texte dans un dossier Maison/
>> Documents/1600_fichiers/00001.txt...01600.txt .
>> Chacun est nommé par un numerto identifiant.Je souhaite realiser
>> deux opérations :
>>
>> 1/ Copier chaque ID dans son fichier
>> 2/ Regrouper le contenus de ces 1600 fichiers dans un seul fichier
>> au format texte
>>
>> Je ne trouve pas comment entrer le nom du fichier dans le texte.
>
>
> --[SCRIPT]
> set dossierSource to "Maison:Documents:1600_fichiers"
> tell application "System Events"
>
> make new file at end of folder dossierSource with properties
> {name:"la_totale.txt"}
> end tell
> set nouveau to dossierSource & "la_totale.txt" as alias
> repeat with i from 1 to 1600
> set source to text -5 thru -1 of ("00000" & i) & ".txt"
> write (return & source & return) to file (dossierSource & source)
> starting at eof
> set textI to read file (dossierSource & source)
> write textI to nouveau starting at eof
> end repeat
> --[/SCRIPT]
>
> devrait fonctionner
>
>
> Yvan KOENIG
>
>
>
>
>
>
>
>
>
>
> De : Yves Petronin <y.petronin@???>
> Date : 2 juin 2009 19:13:15 HAEC
> À : applescript_fr@???
> Objet : [AS] inclure le nom du fichier dans le corps du fichier
> Répondre à : La liste AppleScript Francophone <applescript_fr@???
> >
>
>
> 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
>
>
>
>
>
> De : Yves Petronin <y.petronin@???>
> Date : 2 juin 2009 22:31:05 HAEC
> À : applescript_fr@???
> Objet : [AS] inclure le nom du fichier dans le corps du fichier
> Répondre à : La liste AppleScript Francophone <applescript_fr@???
> >
>
>
>
>
> Voici ce qui pourrait servir à écrire le nom du fichier au début de
> celui-ci. Travail de débutant sans doute très perfectible...et à
> tester..avec prudence car il est assez facile d'écraser un fichier
> La concaténation finale devait être assez facile en utilisant la
> commande aussi la commande cat... S'il y a beaucoup de fichiers à
> traiter, les commandes shell paraissent plus rapides.
>
>
>
> --SCRIPT
>
> set FolderPath to ((path to desktop as string) & "Dossier_test")
>
> set L to list folder (FolderPath) without invisibles
> repeat with i in L
> set thisFile to (FolderPath & ":" & i) as string -- Path to file
> set ThePath to (POSIX path of file thisFile)
>
> set cmd1 to "echo " & (quoted form of i as string) & " > /tmp/
> Temporary_file" -- cree un fichier temporaire et ecrit i au début
> set cmd2 to "cat " & quoted form of ThePath & " >> /tmp/
> Temporary_file"
> set cmd3 to "cat /tmp/Temporary_file > " & quoted form of ThePath
> set cmd4 to "rm /tmp/Temporary_file"
>
> do shell script cmd1 --cree un fichier temporaire et ecrit i
> do shell script cmd2 --ajoute au fichier temporaire le contenu du
> fichier d'origine
> do shell script cmd3 --transfère le contenu du fichier temporaire
> dans le fichier d'origine
> do shell script cmd4 --supprime le fichier provisoire
>
> end repeat
>
> --SCRIPT
>
>
>
>
>
> _______________________________________________
> Applescript_fr mailing list
> Applescript_fr@???
> http://listes.patpro.net/mailman/listinfo/applescript_fr
_______________________________________________
Applescript_fr mailing list
Applescript_fr@???
http://listes.patpro.net/mailman/listinfo/applescript_fr