Page 1 of 1

Need to populate selected comments with contents of a text file

Posted: 09 Jul 2023 04:41
by mrbosco
I have a text file with say 100 lines of text.
I'd like to be able to select 100 rows and execute a script that would populate the comments column with the contents of the text file, one line of text for each comment. I couldn't find any examples of how to do this.

Re: Need to populate selected comments with contents of a text file

Posted: 09 Jul 2023 05:43
by highend
readfile
init $i to 1
foreach loop over <get selecteditemspathnames>
gettoken with $i on the content of the readfile populated variable
check if it is not empty and if true: tagitems on that item
inc $i by 1

Re: Need to populate selected comments with contents of a text file

Posted: 09 Jul 2023 06:45
by mrbosco
I'm a novice to scripting.
Can you show me how it's done?

Re: Need to populate selected comments with contents of a text file

Posted: 09 Jul 2023 14:12
by mrbosco
I think I got it.
Does this look right?

$i=1;
$INPUT=readfile("c:\test\Comment.txt");
foreach($item, <get SelectedItemsPathNames |>, , "e") {
tag gettoken($INPUT,$i,"<crlf>"), $item, 2, 1;
$i++;
}

Re: Need to populate selected comments with contents of a text file

Posted: 09 Jul 2023 14:43
by highend
It should work. But again, I'd test if the gettoken contains something before I (unnecessarily) tag items...