Chercher et Remplacer du texte dans un fichier

Discussion en Français sur NeoBook

Moderator: Neosoft Support

Locked
UltraVox
Posts: 469
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Chercher et Remplacer du texte dans un fichier

Post by UltraVox »

Bonjour à tous,

N'ayant pas utiliser les fonctions avancées de NeoBook depuis assez longtemps, je n'arrive pas à me souvenir comment trouver et remplacer un mot spécifique qui se trouve à une ligne spécifique dans un fichier. Il s'agit d'un fichier DirectX (.X) qui peut se lire comme un .TXT (avec Notepad par exemple).

A la ligne 10 se trouvent les données suivantes :

Code: Select all

  "bottom.dds";
Donc 2 espaces, suivis de "bottom.dds";
Je dois modifier le texte bottom.dds en autre chose, sans toucher au reste, mais je n'y arrive pas.

Quelqu'un a t-il une idée sur la façon de procéder ? Je me perd avec les scripts Str...

D'avance un GRAND merci :)

UltraVox

ENGLISH

Hello everyone,

Not having to use advanced functions of NeoBook long enough, I can not remember how to Find and Replace a specific word which is a specific line in a file. This is a DirectX file (.X) which can be read as a .TXT (with Notepad for example).

At line 10 are the following :

Code: Select all

 "bottom.dds";
So two spaces, followed by "bottom.dds";
I need to change the text bottom.dss to something else, without affecting the rest, but I do not...

Does someone has an idea on how to proceed ? I'm lost with scripts Str...

A BIG thank you in advance :)

UltraVox
User avatar
Fabien
Posts: 137
Joined: Thu Dec 04, 2008 2:31 pm
Location: France - Lyon

Re: Chercher et Remplacer du texte dans un fichier

Post by Fabien »

Salut,

As-tu testé la fonction: StrReplace
¡ sǝıʇɹo sǝl suɐp éɯéɯ sɐd ǝssnod
UltraVox
Posts: 469
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Chercher et Remplacer du texte dans un fichier

Post by UltraVox »

Salut :)

Le problème a été résolu ailleurs sur ce forum, mais merci pour votre réponse.

Et oui, la solution se présentait comme ceci :

Code: Select all

.Read the file contents
FileRead "[PubDir]Sample.txt" "All" "[FileContents]"

.Replace all ocurrences of "bottom.dds" to "something.dss"
StrReplace "[FileContents]" "bottom.dds" "something.dss" "[FileContents]" ""

.Save the replaced contents into the file
FileWrite "[PubDir]Sample.txt" "All" "[FileContents]"
Merci tout de même !
Locked