Page 1 of 1

How to write copy/tags to a NEW file

Posted: 09 Mar 2024 01:40
by Zonko
I'm working on a script to make a new file, and apply the tags of the selected item <curitem> to the new file. Its something like this :

$file=<curitem>;
$newfile = new("<curitem>.deleted.txt");
$tags = tagitems("tags");
tagitems("tags", $tags, $newfile);

Here is the problem - $newfile is newly created, but applying the tags doesn't work. Its feels like the file doesn't actually exist when the tagitems(..) runs.

So end effect is that a new file gets created - it just doesn't have the tags from the existing.

If the file ALREADY exists - this script works to copy the tags over. So I believe my syntax is correct, I'm just experiencing a race condition of trying to apply tags before they can be written. Is there any way to make this work? (preferably in the same script).

$file=<curitem>;
$newfile = "<curitem>.deleted.txt" ;
$tags = tagitems("tags");
tagitems("tags", $tags, $newfile);

Re: How to write copy/tags to a NEW file

Posted: 09 Mar 2024 02:00
by jupe
When you create a new file in current folder, orig selection is lost, so you need to make sure tagitems is getting orig tags from a valid filename, eg.

replace this:
$tags = tagitems("tags");

with this:
$tags = tagitems("tags", , $file);

Re: How to write copy/tags to a NEW file

Posted: 09 Mar 2024 20:18
by Zonko
It works! Thank you.