Page 1 of 1

Recursive Change in ID3 Tags

Posted: Sun Dec 03, 2006 1:58 am
by itsonlychand
Hello

Sorry if it is not right place to post - but i have genuine concern.


GetID3 is great stuff. I have 30,000+ indian, tamil songs hosted on my siite, is there anyway I could change their

Comment, Year Or Genere Information RECURSIVELY ?

I must be having 3000+ Folders holding Mp3 and WMA files. Any help will save years of my hardwork :)

Thanks in Advance for any Help

Posted: Sun Dec 03, 2006 9:54 am
by Allan Hansen
Yes.

The usual way is to write a recursive function to scan the directory structure with opendir() and readdir():

Code: Select all

    function scan_directory($path, &$files)
    {
        if (!$dir = @opendir($path)) {
            // error("Unable to open $path"); 
        }
        
        if (!is_readable($path)) {
            // error("Read access denied to $path"); 
        }
            
        else {
            
            while ($dir && $file = readdir($dir)) {
        
                // directories
                if (is_dir("$path/$file")  &&  $file[0]!='.') {
        
                    // go recursive 
                    $this->scan_directory("$path/$file", $files);
                } 
                
                // files (skip hidden)
                elseif ($file{0} != '.') {
                  
                    $files[] = "$path/$file";                   
                }
            }
            closedir($dir);
        }        
    }
After the function returns, just loop thru the files array and modify the tags.[/code]