Tag and comment copying

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
FKF5482
Posts: 76
Joined: 06 Apr 2019 04:21

Tag and comment copying

Post by FKF5482 »

Hello, i would like to know, how can i copy all tags and comments from a file to another?

Thanks in advance.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag and comment copying

Post by highend »

By scripting it...

Only existing comments / tags are copied, if they are empty, the destination file will not store these empty tags / comment!

Code: Select all

    $selected = <get SelectedItemsPathNames <crlf>>;
    end (gettoken($selected, "count", <crlf>) != 2), "There are NOT two files selected!";

    $text  = "Is the first or the second selected item the source to copy from?";
    $notes = "Enter either 1 or 2...";
    $input = input($text, $notes, "1");
    end (!regexmatches($input, "^(1|2)$")), "No source file defined, aborted!";

    if     ($input == 1) { $src = gettoken($selected, 1, <crlf>); $dst = gettoken($selected, 2, <crlf>); }
    elseif ($input == 2) { $src = gettoken($selected, 2, <crlf>); $dst = gettoken($selected, 1, <crlf>); }

    $comment = tagitems("cmt", , $src);
    $tags    = tagitems("tag", , $src);

    if ($comment) { tagitems("cmt", $comment, $dst); }
    if ($tags)    { tagitems("tag", $tags   , $dst); }
One of my scripts helped you out? Please donate via Paypal

FKF5482
Posts: 76
Joined: 06 Apr 2019 04:21

Re: Tag and comment copying

Post by FKF5482 »

Thank you very much Highend, its working perfectly! :)

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag and comment copying

Post by highend »

This is probably a better one because it allows to copy tag(s) / comment to all selected files even in different multiple directories...

You can change its default behavior by modifying this variable at the beginning:
$copyEmpty = false; // Change to true if you want to clear tag(s) / comment if the source is empty
Copy tag(s), comment_v0.1.xys
(1.95 KiB) Downloaded 150 times
One of my scripts helped you out? Please donate via Paypal

FKF5482
Posts: 76
Joined: 06 Apr 2019 04:21

Re: Tag and comment copying

Post by FKF5482 »

Is it possible to somehow copy all tags and comments from a selected file in pane 1 to the selected file in pane 2. That would make things a lot easier.

With the current script it's only possible to copy when all files are in the samed folder. Unless of course im missing something and in that case please let me know.

Thanks again :)

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag and comment copying

Post by highend »

See this one (v0.2), changelog:

Code: Select all

v0.2
  + Dual pane supported
Copy tag(s), comment_v0.2.xys
(4.3 KiB) Downloaded 94 times
One of my scripts helped you out? Please donate via Paypal

FKF5482
Posts: 76
Joined: 06 Apr 2019 04:21

Re: Tag and comment copying

Post by FKF5482 »

Excellent, this will speed things up!

Thank you again Highend :)

VeeGee

Re: Tag and comment copying

Post by VeeGee »

Good evening,
After forum searching this thread looks like my question fits into it.

I have dual panes. Source on top, Target on bottom. There are TAGS on the folders in the Source pane. What I'd like to do is, if the folder exists in the Target pane, copy the TAG from the matching Source folder to the Target. No specific selections, just process all the folders in Source and check if it matches in Target, if so, copy the TAG.

I am attempting to script this and am thinking it would go something like this :
1. Get a list of folders in Source
2. Loop through the Source folders and check if a match is found in Target
3. If folder name matches, copy the Source TAG to the Target folder

Is this a good approach to this ? I didn't see any built-in tools to do this, so I assumed it was a job for scripting.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Tag and comment copying

Post by highend »

Would work. But you don't want to do this in a

Code: Select all

... outer loop over src folders
   ... inner loop over dst folders
        check for a match
   ...
...
way, right?
One of my scripts helped you out? Please donate via Paypal

Post Reply