Saturday, January 30, 2010

Making of a cd image

Last week, I wanted to write a few files to a cd and give to my father. Those were mp3 files. I tried mkisofs (genisoimage) but the result was not acceptable. Almost all file names were screwed due to name size limitation of iso9660. Also, I did not want the folder hierarchy as I was not sure if my dad's mp3 player will accept it.

Today I sat down to make this happen. There might have been other ways. But, this looked simpler than googling for hours for the most optimum ways....

Write a small program to do the linking...


#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
    int i=0;
    char str[128];


    if(argc>1)
    {
        for(i=1;i<argc;i++)
        {
            memset(str,0,sizeof(str));
            sprintf(str,"ln -s \"%s\" .",argv[i]);
            printf("%s\n",str);
            system(str);

        }
    }

    return 0;
}


Compile it into a program (say lnk)
gcc lnk.c -o lnk

Create a folder to hold the links to your mp3 files & enter that folder
mkdir temp
cd temp

Create the link from source folder to here
find ../mp3-collection/ -name "*.mp3" | xargs -d '\n' ./lnk

Make your iso file...
cd ..
genisoimage -ldots -allow-lowercase -allow-multidot -f -J -joliet-long -r -o temp.iso temp/*

(I spent 5 - 10 minutes reading genisoimage man page. Feel free to do the same. -f: follow sym link, -J: Joilet extn, -r: Rock ridge extn)

you can now mount this and check the file names etc (mount -o loop temp.iso /mnt). After you are happy with your brand new iso image, use wodim to write it to a cd

wodim dev=/dev/cdrw temp.iso

Catch: We are creating sym links from a folder tree to a single folder. This can cause issues with same file name repeating. An enhancement to lnk.c can be to check the return status of 'system' call and then modify the file name string accordingly.

Thursday, January 7, 2010

Google live search results

Click on http://www.google.co.in/search?q=CES+2010 and scroll down to the middle of the page... Google has gone to the next level of searching. Live update of search results more like your twitter. I don't know what they call it or any other details... But, this is cool...