Delai Posted October 28, 2006 Share Posted October 28, 2006 (edited) Hi men i want to change a string in a text, but whitout success, i think the problem is the extension of the text file (.tpr) because the file it writes me contains only "Video-Hol.tpr" and not the text changed, (I think it does not read the file well), here is my script: $search_Project = FileFindFirstFile(".\Scripts\Plantilla\*.tpr") While 1 $Project = FileFindNextFile($search_Project) If @error Then ExitLoop $Project_String = StringSplit( $Project , "-" & "." ) $Project_Text = FileRead($Project,FileGetSize($Project)) $Project_Text = StringReplace ($Project, $Project_String[2], "Hol") FileWrite(".\Scripts\Video-" & $Project_String[2] & ".tpr",$Project_Text) WEnd Edited October 28, 2006 by Delai Link to comment Share on other sites More sharing options...
flyingboz Posted October 28, 2006 Share Posted October 28, 2006 (edited) I can't understand your english or your code. It looks like you've got a potential logic error buried in your renaming function. When you split the array it may not be what you are expecting , depending on the file it's grabbed. It would also be a good idea to familiarize yourself with filehandles if these files are larger than a couple of kb. Test your stringsplit to ensure that the $project_string array is what you expect. Edited October 28, 2006 by flyingboz Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
Delai Posted October 28, 2006 Author Share Posted October 28, 2006 (edited) Video_Capi.txtI have found the problem, it tries to read the archive .tpr but it seems not be able to read it because it has characters, i have attached one example. I have changed the extension of the archive because it does not let me to upload it, so the file is: Video-Capi.tpr I have tested the $project_String and is right. Edited February 23, 2007 by Delai Link to comment Share on other sites More sharing options...
Delai Posted February 23, 2007 Author Share Posted February 23, 2007 (edited) I have tried but without success and finally i decide to try with the simple script that i have copied from here (Forum), and only it works with a normal file, but it does not work with the file generated by a program, it creates the file but only with a character. I have attached the file like as it has generated. Any help pleasehttp://rapidshare.com/files/17875417/Video-Capitulo.tpr.html$szFile = "Video-Capitulo.tpr" $szText = FileRead($szFile,FileGetSize($szFile)) $szText = StringReplace($szText, "Video-Capitulo", "Video-Prueba") FileDelete($szFile) FileWrite($szFile,$szText) Edited February 25, 2007 by Delai Link to comment Share on other sites More sharing options...
Delai Posted February 24, 2007 Author Share Posted February 24, 2007 Anyone would help me please Thanks very much Link to comment Share on other sites More sharing options...
Delai Posted February 25, 2007 Author Share Posted February 25, 2007 Please, is there anybody who can help me please? Thank you very much Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 25, 2007 Moderators Share Posted February 25, 2007 Try reading the file to hex first: $sString = Hex(BinaryString(FileRead('FileName'))) $sHexToFind = Hex(BinaryString('Video-Capitulo')) $sHexToReplaceWith = Hex(BinaryString('Video-Prueba')) $sString = StringReplace($sString, $sHexToFind, $sHexToReplaceWith) FileWrite('OutFileLocation', BinaryString('0x' & $sString)) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Delai Posted February 25, 2007 Author Share Posted February 25, 2007 (edited) Thank you very much @SmOke_N.I will try it and i will inform you later.Thanks again.EDIT:I have tried it in an example, and it seems to work like a charm, i will implement it in my script.Thank you very much again @SmOke_N for your appreciated help Edited February 25, 2007 by Delai Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now