@highend:
Code: Select all
$iTunesFolder = "<curpath>";
$folders = folderreport("dirs", "r", $iTunesFolder, "r", , "<crlf>");
$files = folderreport("files", "r", $iTunesFolder, "r", , "<crlf>");
$matches = regexmatches($files, "^.*?folder\.jpg$", "<crlf>");
if ($matches) {
$foldersToExclude = "";
foreach($match, $matches, "<crlf>") {
if (strpos(report("{attr}", $match), "s") != -1){ // Ignore folder.jpg with system attribute
$foldersToExclude = $foldersToExclude . getpathcomponent($match, "path") . "|";
}
}
}
$folders = regexreplace(replacelist($folders, $foldersToExclude, "", "|"), "^\\.*?$");
paperfolder("iTunes", formatlist($folders, "dents", "<crlf>"), "<crlf>");
In my tests, both the new, faster version of the iTunes/folder.jpg script and original version of that script return all of the folders, regardless of whether or not they contain a standard folder.jpg file. I think it's because $foldersToExclude never gets set by anything other than a $match that has the system attribute. When the If test evaluates as true, the variable gets set, but when it evaluates as false it doesn't. There's no command outside of the if-then block (but still within the foreach block) that modifies $foldersToExclude.
I think I fixed that, but I ran into another problem. Many CDs consist of 2 or more discs (e.g., "The Best Of The Doors [Disc 1]" and "The Best Of The Doors [Disc 2]"), or different CDs are named similarly -- Greatest Hits, Greatest Hits Vol.2 (e.g., Elton John or Linda Ronstadt), The Traveling Wilburys, Vol. 1, The Traveling Wilburys, Vol. 3, and so on. If one of these discs has artwork but the other doesn't, then the regexreplace command truncates the path of the folder we want to keep to just the different characters at the end of the string. For example, "...\Greatest Hits Vol.2" becomes "Vol.2". Obviously, such a folder doesn't exist.
What's the best way to fix these issues?
Thanks,
Jeff