Script for tagging a selection of files
Posted: 25 Apr 2020 04:45
I'm trying to select a bunch of files and run a script that tags each file with portions of it's own filename.
In testing, when I select four files and run this, I get four separate messages with the correct tags that I want to apply to each. So echo1 is the tag for file1, and echo2 is the tag for file2, and so on.
Each tag would look like firstname.lastname as the tag.
But, when I change the last line to this, it applies the last tag to all of the selected items. I've tried leaving the <curitem> spot empty. I tried the tagitems() command with the fiels set to "tags" but that didn't seem to work any differently.
The script obviously works on one item, but it isn't working on a section of items.
In testing, when I select four files and run this, I get four separate messages with the correct tags that I want to apply to each. So echo1 is the tag for file1, and echo2 is the tag for file2, and so on.
Code: Select all
foreach($file, <get SelectedItemsPathNames <crlf>>, <crlf>, "e") {
$filename = getpathcomponent($file, "base");
$filter1 = gettoken($filename, 5,".");
$filter2 = gettoken($filename, 6,".");
$tag = $filter1.".".$filter2;
echo $tag;
}But, when I change the last line to this, it applies the last tag to all of the selected items. I've tried leaving the <curitem> spot empty. I tried the tagitems() command with the fiels set to "tags" but that didn't seem to work any differently.
Code: Select all
tag $tag,<curitem>,1,1;