ok this is how I first did it.
open terminal, install the necessary php if you do not have it
and pasted the following into gedit;
sudo apt-get install php5-cli
note the difference in our folders, and I use folder.jpg instead of Folder.jpg. so make the appropriate changes, save and exit, ** I have put bold comments to areas of the script I have edited **
Used in conjunction with nautilus metafile for music folder Folder.jpg replacement!
$time = mktime();
$dir = "/home/redemma/Multimedia/Music/Hardcore, Metal & Screamo/"; //this is the music directory you wanna change
$filename = $dir . "music.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
$lines = explode ("\n", $contents);
echo "<?xml version=\"1.0\"?>\n<directory>";
foreach ($lines as $value)
//replace special characters.....this is kind of a dumb way to do things, I bet a more leet php coder would be able to find a better function to do this
$newval = str_replace(" ", "%20", $value); //replace spaces
$newval = str_replace(",", "%2C", $newval); //i have some commas in my album names
$newval = str_replace("&", "%26", $newval); //i noticed an ampersand (&) in certain album titles such as Outkast - Speakerboxxx & The Love Below
$filename = $dir . $value . "/folder.jpg"; //changed Folder.jpg to folder.jpg
$time = mktime(); //Unix time!
if (file_exists($filename)) //we only want to do this if there is actually a Folder.jpg file in there
$size = filesize($filename);
if ($size && $size < 1048576) //if the Folder.jpg file is too big we might have problems, so lets limit it to 1 MB
echo "<file name=\"" . $newval . "\" timestamp=\"". $time . "\" custom_icon=\"folder.jpg\"/>"; //again changed Folder.jpg to folder.jpg
}//end if statment: file_exists
} //end foreach
clearstatcache(); //not really sure if we need this
Now cd to your music directory, and then create a list of folders, so I did this;
chmod 755 icons.php
this should create the music.txt in your music folder for me its just where I keep all my metal and hardcore cds. now the final step is to run icons.php so from here; or from home, thats what I did; just make sure you use your metafile, and not exactly what I do in the second line. if your run from your music folder make sure you put the full path to icons.php!
cd ./Multimedia/Music/Hardcore\,\ Metal\ \&\ Screamo/
ls > music.txt
go to the directory and viola!
php icons.php > /home/redemma/.nautilus/metafiles/file\:%2F%2F%2Fhome%2Fredemma%2FMusic%2FHardcore%252C%2520Metal%2520%2526%2520Screamo.xml