Script for tagging a selection of files

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
muzicman82
Posts: 19
Joined: 19 Dec 2019 20:48

Script for tagging a selection of files

Post 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.

highend
Posts: 15016
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Script for tagging a selection of files

Post by highend »

Using $file instead of <curitem> doesn't make a little bit more sense to you?
One of my scripts helped you out? Please donate via Paypal

muzicman82
Posts: 19
Joined: 19 Dec 2019 20:48

Re: Script for tagging a selection of files

Post 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.

Post Reply