Today I created 2 Custom Columns and I'd like to share them. I have movie/TV folders and files in name (year) format. I wanted new columns that rearrange The, A movies and a column to show just the year.
For example, This way I can have a few more sorting options without having to rename my folders or files. Plus I've been wanting to do some more scripting and use Custom Columns.
Here are my snippets of code. As I experiment more I'm sure they can be shortened by quite a bit. I'm also sure highend will have a one-line solution to replace them
Movie Title :
Code: Select all
$base = getpathcomponent(<cc_name>, "base");
$defaultmodamount = 7;
if(strpos($base, "A ") == 0) {
$startend = 2;
if(strpos($base, ")") > 0) {
$modamount = $defaultmodamount;
} else {
$modamount = 0;
}
$modlength = $strlen($base) - $modamount;
} elseif(strpos($base, "The") == 0) {
$startend = 4;
if(strpos($base, ")") > 0) {
$modamount = 11;
} else {
$modamount = 0;
}
$modlength = strlen($base) - $modamount;
} else {
if(strpos($base, ")") > 0) {
return substr($base, 0, strlen($base) - $defaultmodamount);
exit;
} else {
return $base;
exit;
}
}
$basea = substr($base, $startend, strlen($base) - $startend);
$baseb = substr($basea, 0, $modlength);
$basec = substr($base, 0, strlen($base) - $defaultmodamount);
if(strpos($base, "A ") == 0) {
return trim($baseb . ", A");
} elseif(strpos($base, "The") == 0) {
return trim($baseb . ", The");
} else {
return trim($basec);
}
Code: Select all
$base = getpathcomponent(<cc_name>, "base");
if(strpos($base, ")") > 0) {
return substr($base, -5, 4);
}