Recursive Change in ID3 Tags

The place for "I can't figure out how to..." questions.
Post Reply
itsonlychand
User
Posts: 1
Joined: Sun Dec 03, 2006 1:53 am

Recursive Change in ID3 Tags

Post by itsonlychand » Sun Dec 03, 2006 1:58 am

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

Allan Hansen
getID3() v2 developer
Posts: 445
Joined: Sun May 04, 2003 2:22 pm
Location: Holmegaard, Denmark

Post by Allan Hansen » Sun Dec 03, 2006 9:54 am

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]

Post Reply