GodlessSinner Posted September 1, 2009 Posted September 1, 2009 I have a file (3.43GB) and need to remove the last 5 bytes, without copying first (3.43GB - 5bytes). How? thanks. _____________________________________________________________________________
dbzfanatic Posted September 1, 2009 Posted September 1, 2009 This is all I can think of. I haven't tested it, just wrote it here. Hope it works for you. $file = FileOpen("filename",18) $data = FileRead($file) $bytes = StringSplit($data,"") For $i = $bytes[0] - 6 To $bytes[0] - 1 $bytes[$i] = "" Next $new_data = _ArrayToString($bytes,"",1) FileWrite($new_data) Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
Manjish Posted September 1, 2009 Posted September 1, 2009 (edited) (Deleting my prev post) Oh now I get what he means.. @dbz.. so u r assuming its a textfile? 3.43 gb large? kind of unlikely don't you think? Edited September 1, 2009 by Manjish [font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
dbzfanatic Posted September 1, 2009 Posted September 1, 2009 That's why it's reading in byte mode. You can open any file, not just text files. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
picaxe Posted September 1, 2009 Posted September 1, 2009 Try#include <WinAPI.au3> $sFile = @ScriptDir & "\largefile" $iTrim = 5 ; bytes to remove from end $hFile = _WinAPI_CreateFile($sFile, 2, 4) _WinAPI_SetFilePointer($hFile, FileGetSize($sFile) - $iTrim) ConsoleWrite("Start " & $sFile & " " & FileGetSize($sFile) & " bytes" & @LF) _WinAPI_SetEndOfFile($hFile) _WinAPI_CloseHandle($hFile) ConsoleWrite("Trimmed " & $sFile & " " & FileGetSize($sFile) & " bytes" & @LF)
GodlessSinner Posted September 1, 2009 Author Posted September 1, 2009 To @Manjish and @dbzfanatic, - Neither that, nor another:) I haven't enough free space to copy first 3.43Gb-5Bytes, and I haven't enough RAM to do that so, like you say.. _____________________________________________________________________________
dbzfanatic Posted September 1, 2009 Posted September 1, 2009 picaxe's version should work. It just opens the file,not copying it. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
GodlessSinner Posted September 1, 2009 Author Posted September 1, 2009 picaxe's version should work. It just opens the file,not copying it.- Sould, but:>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe..... Start E\Fedora-11-i386-DVD.iso 0 bytesand then MsgBox(0, "Error", "_WinApi_CloseHandle: Incorrect descriptor.") _____________________________________________________________________________
99ojo Posted September 1, 2009 Posted September 1, 2009 - Sould, but:>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe..... Start E\Fedora-11-i386-DVD.iso 0 bytesand then MsgBox(0, "Error", "_WinApi_CloseHandle: Incorrect descriptor.")Hi,Start E\Fedora-11-i386-DVD.isoHave a look at file name. There is a : missing;-))Stefan
picaxe Posted September 1, 2009 Posted September 1, 2009 This is better and should work for files > 2^32 bytes#include <WinAPI.au3> $sFile = @ScriptDir & "\zzz.avi" $iTrim = 5 ; bytes to remove from end $hFile = _WinAPI_CreateFile($sFile, 2, 4) _WinAPI_SetFilePointer($hFile, - $iTrim, 2) ConsoleWrite("Start " & $sFile & " " & FileGetSize($sFile) & " bytes" & @LF) _WinAPI_SetEndOfFile($hFile) _WinAPI_CloseHandle($hFile) ConsoleWrite("Trimmed " & $sFile & " " & FileGetSize($sFile) & " bytes" & @LF)
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