This didn't turn out nearly as nice as I wanted it to, but if anyone wants to toy with it, be my guest.
Command:
php printid3info.php -i -l /Users/william/Documents/Programming/php/getid3-1.7.9/getid3/getid3.php -f %artist, %album, %year, %genre, %title < printid3list.txt
Input file:
/Users/william/Music/iTunes/iTunes Music/Music/Anberlin/Lost Songs/01 The Haunting.mp3
/Users/william/Music/iTunes/iTunes Music/Music/Journey/Journey's Greatest Hits/02 Don't Stop Believin'.m4a
/Users/william/Music/iTunes/iTunes Music/Music/Rick Astley/Whenever You Need Somebody/01 Never Gonna Give You Up.mp3
Output:
Library path switched to: /Users/william/Documents/Programming/php/getid3-1.7.9/getid3/getid3.php
Format set: %artist, %album, %year, %genre, %title
Enter absolute filename: Anberlin, Lost Songs, 2007, Other, The Haunting
Enter absolute filename: Journey, Journey's Greatest Hits, %year, %genre, Don't Stop Believin'
Enter absolute filename: Rick Astley, Whenever You Need Somebody, 1987, Other, Never Gonna Give You Up
Enter absolute filename: Error opening
#!/bin/php
<?php
//
// ID3 Tag Info Printer
// Written by joe[x86]
// Based on getID3 by James Heinric
// http://www.getid3.org
//
// set defaults
$libpath = "/usr/include/getid3/getid3.php";
$format = "%artist - %title";
// parse commandline input
for ($i = 1; $i < $argc; $i++) {
if ($argv[$i] == "-h") {
echo "Usage: php printid3info.php [-h | -v | -l libpath | -f format]\n";
echo "-h: Help. Displays this message.\n";
echo "-v: Verbose. Incomplete.\n";
echo "-l: Library path.";
echo "-f format: Replaces the following format codes:\n";
echo " %title, %artist, %album, %year, %track, %genre\n";
echo " Uses \"%artist - %title\\n\" by default. Must be last argument\n";
die();
} else if ($argv[$i] == "-v") {
echo "Verbose mode not complete.\n";
} else if ($argv[$i] == "-l") {
$i++;
$libpath = $argv[$i];
echo "Library path switched to: $libpath\n";
} else if ($argv[$i] == "-f") {
// begin accepting format
$format = "";
for ($j = $i + 1; $j < $argc; $j++) {
$format .= " " . $argv[$j];
}
$format = trim($format);
echo "Format set: $format\n";
}
}
// include library
if(@!include($libpath))
die("Missing getID3 library at $libpath\n");
$getID3 = new getID3;
while(true) {
echo "Enter absolute filename: ";
$filename = trim(fgets(STDIN));
$fileinfo = $getID3->analyze($filename);
getid3_lib::CopyTagsToComments($fileinfo);
if (array_key_exists('comments', $fileinfo)) {
$output = $format;
if (array_key_exists("title", $fileinfo['comments']))
$output = str_replace("%title", $fileinfo['comments']['title'][0], $output);
if (array_key_exists("artist", $fileinfo['comments']))
$output = str_replace("%artist", $fileinfo['comments']['artist'][0], $output);
if (array_key_exists("album", $fileinfo['comments']))
$output = str_replace("%album", $fileinfo['comments']['album'][0], $output);
if (array_key_exists("year", $fileinfo['comments']))
$output = str_replace("%year", $fileinfo['comments']['year'][0], $output);
if (array_key_exists("track", $fileinfo['comments']))
$output = str_replace("%track", $fileinfo['comments']['track'][0], $output);
if (array_key_exists("genre", $fileinfo['comments']))
$output = str_replace("%genre", $fileinfo['comments']['genre'][0], $output);
echo $output . "\n";
} else {
echo "Error opening $filename\n";
die();
}
// display all variables
/*foreach($fileinfo['comments'] as $key => $value) {
echo "$key => $value\n";
}*/
}
?>