Name down
Posted: 21 Jun 2016 17:09
I needed this today, it's a bit special but maybe you have a use for it, too.
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:
Now I want a clear connection between the two files. They should have the same name:
This script will do that in one click when the files are listed one after the other and the source file (the name to be used) is focused:
Just a quickie that covers my needs so far.
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.txtCode: Select all
knife-throwing-ex05.jpg
knife-throwing-ex05.txtCode: 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";
}
}