Append labels (as words) and tags to file names (selected)
Re: Append labels (as words) and tags to file names (selected)
XYplorer 18.10.0000
Windows 8 Optimizations [Blue; Win8].mp4
(Win8 — set.)
"XYplorer File Tags v4
Labels:
Red|FC7469|010101;Orange|F3D2BC|010101;Yellow|F9F3BF|010101;Green|93C8B0|010101;Blue|6CB5FD|010101;Purple|E29CDD|010101;Grey|B5B5B5|010101;Roland_Juno-G|BE00C4|010101;White|FFFFFF|010101;Rose|FFD9EC|010101;Vinous|B86177|010101;Silver|E8F7F4|010101;Azure|00DFFF|010101;Khaki|62824A|010101;Gold|E4DAAF|010101
Extra Tags:
|0|0|0|||||
|0|0|0|||||
|0|0|0|||||
|0|0|0|||||
|0|0|0|||||
Storage: 1 (Relative to application drive)
Data: "
v18 is portable.
Windows 8 Optimizations [Blue; Win8].mp4
(Win8 — set.)
"XYplorer File Tags v4
Labels:
Red|FC7469|010101;Orange|F3D2BC|010101;Yellow|F9F3BF|010101;Green|93C8B0|010101;Blue|6CB5FD|010101;Purple|E29CDD|010101;Grey|B5B5B5|010101;Roland_Juno-G|BE00C4|010101;White|FFFFFF|010101;Rose|FFD9EC|010101;Vinous|B86177|010101;Silver|E8F7F4|010101;Azure|00DFFF|010101;Khaki|62824A|010101;Gold|E4DAAF|010101
Extra Tags:
|0|0|0|||||
|0|0|0|||||
|0|0|0|||||
|0|0|0|||||
|0|0|0|||||
Storage: 1 (Relative to application drive)
Data: "
v18 is portable.
Re: Append labels (as words) and tags to file names (selected)
I should've changed <xydata> to the actual path, shouldn't I?
Re: Append labels (as words) and tags to file names (selected)
"
$labels = regexmatches(readfile("E:\Programs Portable\XYplorer 18.10.0000 (10-Jul-2017)\Data\tag.dat", , 2000), "^((.+?)\|\|(.+?)){7,}$");
"
Still doesn't work for labels.
There are spaces in the path. Or does XYplorer not require the path itself?
$labels = regexmatches(readfile("E:\Programs Portable\XYplorer 18.10.0000 (10-Jul-2017)\Data\tag.dat", , 2000), "^((.+?)\|\|(.+?)){7,}$");
"
Still doesn't work for labels.
There are spaces in the path. Or does XYplorer not require the path itself?
Re: Append labels (as words) and tags to file names (selected)
Do not change <xydata>...
And try this:
And try this:
Code: Select all
end (compare(<xyver>, "18.00.0021", "v") == -1), "You need at least v18.00.0021 of XYplorer, aborted!";
$labels = regexmatches(readfile("<xydata>\tag.dat", , 2000), "^((.+?)\|([A-F0-9]{6})?\|([A-F0-9]{6})){7,}$");
$labels = trim(regexreplace($labels, "\|([A-F0-9]{6})?\|[A-F0-9]{6};?", "|"), "|");
foreach($file, <get "SelectedItemsPathNames" <crlf>>, <crlf>, "e") {
// Ignore folders
if (exists($file) == 2) { continue; }
// Find [<label name>;<tag>]
$base = gpc($file, "base");
$match = regexreplace(regexmatches($base, "\[[^]]*;[^]]*\]"), "\[|\]");
if (!$match) { continue; }
// Get label index from label name + tag
$labelName = trim(gettoken($match, 1, ";"));
$labelIndex = gettokenindex($labelName, $labels);
$tag = trim(gettoken($match, 2, ";"));
// Label + tag item
if ($labelIndex) { tagitems("label", $labelIndex, $file); }
if ($tag) { tagitems("tags", $tag, $file); }
}
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Yes! It works with every label, and with groups of files.
Thank you!
Thank you!
Re: Append labels (as words) and tags to file names (selected)
Here I go again, after a while... Hello.
Turns out, this script:
doesn't update the [label; tag] parts of the file names,
it just adds, appends another [label; tag] part, so
File Name [label; tag].ext
becomes
File Name [label; tag] [label; tag].ext
Can this be fixed?
(XYplorer 18.20.0200)
Turns out, this script:
Code: Select all
end (compare(<xyver>, "18.00.0021", "v") == -1), "You need at least v18.00.0021 of XYplorer, aborted!";
foreach($file, <get "SelectedItemsPathNames" <crlf>>, <crlf>, "e") {
// Ignore folders
if (exists($file) == 2) { continue; }
$label = tagitems("label", , $file, 2);
$tags = tagitems("tags", , $file);
if (!$label && !$tags) { continue; }
else {
$base = gpc($file, "base");
$ext = gpc($file, "ext");
renameitem("$base [$label; $tags].$ext", $file);
}
}
it just adds, appends another [label; tag] part, so
File Name [label; tag].ext
becomes
File Name [label; tag] [label; tag].ext
Can this be fixed?
(XYplorer 18.20.0200)
Re: Append labels (as words) and tags to file names (selected)
The $base in the renameitem() line already contains the old [tag; label]...
Remove it e.g. via a regexreplace() first
Remove it e.g. via a regexreplace() first
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Sorry, I don't know how the script should look when finished.The $base in the renameitem() line already contains the old [tag; label]...
Remove it e.g. via a regexreplace() first
Only "copy-paste" here, in this area...
Re: Append labels (as words) and tags to file names (selected)
Code: Select all
$base = regexreplace(gpc($file, "base"), "([ ]+\[.+?\])");
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Thank you.
Updated.
Updated.
Re: Append labels (as words) and tags to file names (selected)
Hello again. Actually, such a script (removing only the [from label; from tag] from the file name) might come in handy, if I wanted to share some files with "clean" names (while XYplorer would remember the labels and the tags).
And I don't know how to remove ' [from label; from tag]' with Search and Replace... , because the text inside the [] varies.
Re: Append labels (as words) and tags to file names (selected)
By reading the label + tag and then remove the combined "[some label; some tag]" from the file (base) name?
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Then go for it? All necessary elements (for loop, reading label + tag, renaming an item) are all part of the various script snippets in this thread...
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Labels & Tags TO Delete in File Names.xys
Seems to work. I hope I haven't overlook anything.
Code: Select all
end (compare(<xyver>, "18.00.0021", "v") == -1), "You need at least v18.00.0021 of XYplorer, aborted!";
foreach($file, <get "SelectedItemsPathNames" <crlf>>, <crlf>, "e") {
// Ignore folders
if (exists($file) == 2) { continue; }
$label = tagitems("label", , $file, 2);
$tags = tagitems("tags", , $file);
if (!$label && !$tags) { continue; }
else {
$base = regexreplace(gpc($file, "base"), "([ ]+\[.+?\])");
$ext = gpc($file, "ext");
renameitem("$base.$ext", $file);
}
}