Ptifou78 Posted May 19, 2012 Share Posted May 19, 2012 Hello everybody I would like to know how to erase *n bits into a file previously open with de the binary mod I have an idea is to read all bit what i need and rewrite a new file but is very slow :/ Thanks in advance Link to comment Share on other sites More sharing options...
water Posted May 19, 2012 Share Posted May 19, 2012 If you know the position of the data in the file you can use function FileSetPos to overwrite the data. The following example writes an "x" at position 10 of a text file. $hFile = FileOpen("C:\temp\test.txt", 1) $iPos = FileSetPos($hFile, 10, 0) FileWrite($hFile, "x") FileClose($hFile) You need to change the script to replace binary data. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted May 19, 2012 Share Posted May 19, 2012 My example overwrites data but if you really need to erase (remove) the data (so the file gets shorter) then there is no other way then rewriting the file as you already do. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Ptifou78 Posted May 19, 2012 Author Share Posted May 19, 2012 Shit and i can not do a string replace like? ^^' Link to comment Share on other sites More sharing options...
water Posted May 19, 2012 Share Posted May 19, 2012 How big is the file you need to process? What have you coded so far? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Ptifou78 Posted May 19, 2012 Author Share Posted May 19, 2012 I have multiple file to process from 1/2mb to 40mb... :/ $F_output = @ScriptDir&"test_output.txt" $F_input = @ScriptDir&"test.txt" FileOpen($F_output,17) FileOpen($F_input,17) Filewrite($F_output,'header') FileSetPos($F_input,128,0);lenght of header $nb_ligne = Hex_to_int32(FileRead($F_input,4)) For $i to $nb_ligne $1st_part = FileRead($F_input,xxx bit) FileSetPos($F_input,4,1);bits to skip $2nd_part = FileRead($F_input,xxx bit) FileWrite($F_output,$1st_part&$2nd_part) Next MsgBox(0,"","Finnish") Link to comment Share on other sites More sharing options...
water Posted May 19, 2012 Share Posted May 19, 2012 To enhance performance you could read the file in one go using FileRead without setting the number of characters to read. Then use StringReplace($StringContainingTheFile, $StringToReplace, "") and then write the file in one go using FileWrite. That should enhance performance considerable. One question. What kind of files do you want to remove binary content? Pictures ...? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Ptifou78 Posted May 19, 2012 Author Share Posted May 19, 2012 I can't because the string is not always the same It's a rdb file for a game it contain some information about data i jjust want to extract them but for that i need to change a litlle bit his structur Moreover i have a stupid question if i do that $data_original = fileread($myfile) Filewrite($my_outputfile,$daata_original If the data original is a binary content i need to translate it for rewrite it or is good? Link to comment Share on other sites More sharing options...
water Posted May 19, 2012 Share Posted May 19, 2012 Would you be so kind to tell us the name of the game? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Ptifou78 Posted May 19, 2012 Author Share Posted May 19, 2012 (edited) Rappelz a MMoRPG is not a crack i just want it for have model data to use in my art work >.< Edited May 19, 2012 by Ptifou78 Link to comment Share on other sites More sharing options...
Valik Posted May 19, 2012 Share Posted May 19, 2012 This thread was perfectly fine right up until you mentioned that you were violating our forum rules. Thread locked. I suggest reading the rules before you post again. Link to comment Share on other sites More sharing options...
Recommended Posts