Editing File Headers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Editing File Headers
# 1  
Old 07-29-2011
Editing File Headers

Hey Guys,

Absolute neewbie here. I am trying to see if it is possible to edit headers/meta-data of files in Mac OSX. I am basically trying to change an audio file header to read 16bit instead of 24bit.

We have an issue with some of our software and it regularly exports 16bit audio files with 24bit headers (so any other software will read the file as 24bit when in fact it is 16bit).

I am trying to see if it is possible to edit the meta-data/header to read 16bit without making another generation of the file. If I want another generation I can use afconvert in terminal. I would like to edit the data of the file without recreating it.

I hope you guys can help.

With Kind Regards


Andy
# 2  
Old 07-29-2011
If you know the differences, you can move the data to a new file using the byte or character options of head and tail, and insert the different bytes in the middle. If they are not text bytes, you can use tr to turn text to binary, like a to 21 octal:
Code:
echo a|tr a '\21'

To mangle it in place, use C or PERL to seek and write the correct bytes. I would doubt the file has a checksum on the header/metadata.
# 3  
Old 08-01-2011
Dear DGPickett,

Many thanks for the reply.

I am still trying to get my head around all of this. Like I said I am a complete newbee. Are you suggesting moving the audio data to a new file with correct headers?

With Kind Regards


Andy
# 4  
Old 08-01-2011
Yes, the effect is the same, give or takes some renaming. Update in place destroys the original if anything goes wrong, and requires much more sophisticated tools. Most text tools truncate as they write. You need a very serious language, like PERL or C, to update the middle. Maybe it is a mindset hangover from tape, where, generally, the last thing you wrote is implicitly just before EOF.

A header could contain a file length and checksum as well as data type and format type magic strings, making updates more complex, but they are less popular in audio/video as you do not know these until the end, long after the header is written, and they do not want to go back and update, either.

Getting a patch to the software would be even nicer. I have patched stings in library file object code using a binary find and replace copier, and scary thing is, no checksum alarms went off! Maybe we need secure ELF? But these few bits are harder to locate and may break other things if you change them.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Cannot find logical file format for BSD file headers.

Hi. Unix rookie here. Been looking for a few days for reference documents on how BSD UNIX lays the logical file format onto a disk. Goal is to view/edit with hex editor for data repair. Lots of docs are available for how to use Unix commands (like xxd), but I want to learn the map of how Unix... (4 Replies)
Discussion started by: Chris_top_he_r
4 Replies

2. UNIX for Dummies Questions & Answers

Append file name to fasta file headers in Linux

How do we append the file name to fasta file headers in multiple fasta-files in Linux? (10 Replies)
Discussion started by: Mauve
10 Replies

3. Shell Programming and Scripting

Merging File with headers

Hi I need to merge 4 files. The issue i am facing is all the files have headers and i do not want them in the final output file. Can anybody suggest how to do it? (5 Replies)
Discussion started by: Arun Mishra
5 Replies

4. Shell Programming and Scripting

editing headers

Hi, I have a folder that contains many (multiple) files 1.fasta 2.fasta 3.fasta 4.fasta 5.fasta . . 100's of files Each such file have data in the following format for example: vi 1.fasta 58 390 A GTATACATTATTGATGAAGTCCACATGCTTTCTATGGGTGCCTTCAATGCGCTTTTAAAA (7 Replies)
Discussion started by: Lucky Ali
7 Replies

5. Shell Programming and Scripting

Multiple headers in a file

Hi , I have a .txt file in which I have multiple headers, the header record starts with $ symbol...like the first column name is $Account. I have to keep the header in the first line and delete all the remaining headers which are in the file. I tried using sort adc.txt | uniq -u , but my... (7 Replies)
Discussion started by: gaur.deepti
7 Replies

6. Shell Programming and Scripting

Editing headers

Hi, I have a folder that contains many (multiple) files 1.fasta 2.fasta 3.fasta 4.fasta 5.fasta . . 100's of files Each such file have data in the following format for example: vi 1.fasta >AB_1 200bp MLKKPIIIGVTGGSGGGKTSVSRAILDSFPNARIAMIQHDSYYKDQSHMSFEERVKTNYDHPLAFDTDFM... (4 Replies)
Discussion started by: Lucky Ali
4 Replies

7. Shell Programming and Scripting

Merging of files with different headers to make combined headers file

Hi , I have a typical situation. I have 4 files and with different headers (number of headers is varible ). I need to make such a merged file which will have headers combined from all files (comman coluns should appear once only). For example - File 1 H1|H2|H3|H4 11|12|13|14 21|22|23|23... (1 Reply)
Discussion started by: marut_ashu
1 Replies

8. UNIX for Dummies Questions & Answers

reading file headers

Hello, I have done much googling on this, but apparently not using the right keywords. I am assuming there is some kind of header for each file on a disk which stores information such as mod time, access time, etc. I have two questions: 1) is there a way to read this header directly,... (2 Replies)
Discussion started by: Allasso
2 Replies

9. Shell Programming and Scripting

Remove text between headers while leaving headers intact

Hi, I'm trying to strip all lines between two headers in a file: ### BEGIN ### Text to remove, contains all kinds of characters ... Antispyware-Downloadserver.com (Germany)=http://www.antispyware-downloadserver.c om/updates/ Antispyware-Downloadserver.com #2... (3 Replies)
Discussion started by: Trones
3 Replies

10. Shell Programming and Scripting

Remove Headers throughout a data file

I have a data file with over 500,000 records/lines that has the header throughout the file. SEQ_ID Name Start_Date Ins_date Add1 Add2 1 Harris 04/02/08 03/02/08 333 Main Suite 101 2 Smith 02/03/08 01/23/08 287 Jenkins SEQ_ID Name ... (3 Replies)
Discussion started by: psmall
3 Replies
Login or Register to Ask a Question