Code: Select all
global $File, $FileName;
$SelectedItems = get("SelectedItemsPathNames", "|");
foreach($Item, $SelectedItems, "|") {
$File = $Item;
sub "_SplitFileName";
$Title = property("DocTitle", "$Item");
$Author = property("DocAuthor", "$Item");
if($Title != "" && $Author != "") {
$NewName = "$Author" . "_" . "$Title" . "_" . "$FileName";
rename b, "$NewName", p, "$Item";
}
}
"_SplitFileName"
global $File, $FileName;
// Separate file components
$FindBS = strpos($File, "\", -1);
$FindExt = strpos($File, ".", -1);
$FileName = substr($File, $FindBS +1, ($FindExt - $FindBS -1));
It's not that I don't trust you. I don't trust the property command (or better: the OS that returns back a value). The same script will fail miserably on my OS while it works for perseid and I like to prefer a solution that works on all systems.