[SOLVED] Want to remove a few bytes from the header of several binary files
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Want to remove a few bytes from the header of several binary files
I have a large set of binary wav files that I want to batch process. However the first few bytes of those files contains extraneous information that prevents the files from being opened in an audio program. So what I want to do is remove the first 12 bytes from each file, so that the file header becomes a vanilla Wave file header. I can do this in hex editors like Bless, but I don't know of one which can do it as a batch operation.
The exact hex characters I want to remove from the file are these ones:
Code:
66 73 73 6D 01 00 00 00 01 00 00 00
I figure one of you programming types would be able to help me with the problem.
Cheers.
Last edited by Zero Angel; 09-16-2011 at 01:51 AM.
Now I need to find a way to make into a batch operation for all files in a given directory. Not sure how to do that as my scripting knowledge is fairly basic and i'm not well versed in for-each type commands.
I just tested corp769's solution and it seems to be the best one due to its simplicity. Now I need to find a way to do it in batch for every file in the folder. Can anyone help me with that -- or point me in the direction of a tutorial which will tell me how to batch commands like that?
Last edited by Zero Angel; 09-16-2011 at 02:09 AM.
To save myself a bunch of typing, have a look here - http://www.cyberciti.biz/faq/bash-loop-over-file/
Looping through files in bash is a very simple task, you just need to mess with it so you get the proper output and filenames.
No problem dude. I would gladly help you make the script, but I'm at work, and sadly enough, the government has a contract with microsoft, and I'm stuck using windows for the time being....
Word splitting is a very important concept in scripting/shell use. Make sure you get it down.
2) Extracting substrings from variables can usually be done with parameter substitutions, making external tools like basename unnecessary most of the time.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.