Page 1 of 1

How to get tags in batch rename?

Posted: 22 Aug 2023 14:21
by minikyu
I want to add tags to my filenames in batch, because not all computers have xyplorer. So can I get the tags of the files from a script in "special rename -> batch rename "? Something like <date yyyy-mm-dd>, just use <tag>.

Re: How to get tags in batch rename?

Posted: 22 Aug 2023 15:00
by highend
No, that variable isn't supported in that context.

You would need to loop over all selected items, read the tags and rename the item with that info...

E.g.:

Code: Select all

    // Rename items by adding their tags
    setting "BackgroundFileOps", 0;
    foreach($item, <get SelectedItemsPathNames>, <crlf>, "e") {
        $base = gpc($item, "base");
        $ext  = gpc($item, "ext");
        $tags = tagitems("tags", , $item);
        if ($tags) {
            $tags = regexreplace($tags, "(<|>|:|""|/|\\|\||\?|\*)", "_");
            $name = $base . " - " . $tags;
            if (exists($item) == 1) { $name .= "." . $ext; }
            renameitem($name, $item);
        }
    }