Page 1 of 1

Script for tagging a selection of files

Posted: 25 Apr 2020 04:45
by muzicman82
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.

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;
}
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.

Code: Select all

tag $tag,<curitem>,1,1;
The script obviously works on one item, but it isn't working on a section of items.

Re: Script for tagging a selection of files

Posted: 25 Apr 2020 05:51
by highend
Using $file instead of <curitem> doesn't make a little bit more sense to you?

Re: Script for tagging a selection of files

Posted: 25 Apr 2020 05:55
by muzicman82
highend wrote: ↑25 Apr 2020 05:51 Using $file instead of <curitem> doesn't make a little bit more sense to you?
Ahh, right I missed that $file was the loop token.