Use case: I often download images and accompanying text bits from websites, both by drag and drop. So I have these files side by side in my drop target folder:
Code: Select all
knife-throwing-ex05.jpg
DroppedText-20160621.txt
Code: Select all
knife-throwing-ex05.jpg
knife-throwing-ex05.txt
Code: Select all
// 20160621: name the item after the focused item like the focused item
$focpos = get("focusedpos");
$focitem = get("item", , $focpos);
$nextitem = get("item", , $focpos + 1);
if ($focitem) {
$focbase = gpc($focitem, "base");
$newname = renameitem($focbase, $nextitem, , "-01");
if ($newname) {
status "rename done, new name: " . gpc($newname, "file");
} else {
status "rename failed, old name: " . gpc($nextitem, "file"), , "alert";
}
}