How to add extra data to the end of the file? [solved]
-
- Posts: 2
- Joined: Sat Mar 05, 2016 1:16 pm
How to add extra data to the end of the file? [solved]
I have a file "file.fle". It's size 40 bytes. I need add 5 bytes (01 fe 48 9a 53) to its end and keep 40 original bytes at the beginning. New size of "file.fle" should be 45 bytes. I tried to use MEMORY_FILE, PutVarChr, append commands but i'm stuck. How to write right bms script for that?
Last edited by Shiroi Bara on Sat Mar 05, 2016 3:53 pm, edited 1 time in total.
-
- Site Admin
- Posts: 12984
- Joined: Wed Jul 30, 2014 9:32 pm
Re: How to add extra data to the end of the file?
A solution can be the following:
Code: Select all
set NAME string "new_file.fle"
set MEMORY_FILE binary "\x01\xfe\x48\x9a\x53"
get SIZE asize
log NAME 0 SIZE
append
log NAME 0 5 MEMORY_FILE
-
- Posts: 2
- Joined: Sat Mar 05, 2016 1:16 pm
Re: How to add extra data to the end of the file?
Thank you very much for quick response! I just replaced first string in you code on (i'm using one script to add same data for different files):
and it works perfect.
Code: Select all
Get NAME filename
and it works perfect.
-
- Site Admin
- Posts: 12984
- Joined: Wed Jul 30, 2014 9:32 pm
Re: How to add extra data to the end of the file? [solved]
Yeah good.
Usually I prefer to create a new file, for example with some instructions like the following:
It may be a good suggestion for the future.
Usually I prefer to create a new file, for example with some instructions like the following:
Code: Select all
get NAME basename
get EXT extension
string NAME + "_new."
string NAME + EXT