Append labels (as words) and tags to file names (selected)
Append labels (as words) and tags to file names (selected)
Hello. I hope I've chosen the forum section right.
Since there's no Mac version of XYplorer and I have a lot of info in tags by now,
I'm interested in possibility to add this info to file names.
For example, the file
File Name.ext
with label 'Blue'
and with a tag 'main part from 5m47s'
would look like this:
File Name [Blue; main part from 5m47s].ext
still with label 'Blue'
and with a tag 'main part from 5m47s'
(they shouldn't be removed).
(Space and square braces — so I know it's from label and tag.)
For selected files only — so you can "update" the new file names without rewriting the old ones.
Does such script exist or can it be made?
Thanks.
Since there's no Mac version of XYplorer and I have a lot of info in tags by now,
I'm interested in possibility to add this info to file names.
For example, the file
File Name.ext
with label 'Blue'
and with a tag 'main part from 5m47s'
would look like this:
File Name [Blue; main part from 5m47s].ext
still with label 'Blue'
and with a tag 'main part from 5m47s'
(they shouldn't be removed).
(Space and square braces — so I know it's from label and tag.)
For selected files only — so you can "update" the new file names without rewriting the old ones.
Does such script exist or can it be made?
Thanks.
Re: Append labels (as words) and tags to file names (selected)
Does only work with at least v18.00.0021 or newer...
Files without label AND tags are NOT renamed!
If you want to change that, change
to
Files without label AND tags are NOT renamed!
If you want to change that, change
Code: Select all
if (!$label && !$tags) { continue; }
else { renameitem("* [$label; $tags]", $file); }
Code: Select all
renameitem("* [$label; $tags]", $file);
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 { renameitem("* [$label; $tags]", $file); }
}
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Hi, highend, and thank you.
Re: Append labels (as words) and tags to file names (selected)
If there's a dot ( . ) somewhere in a tag, the script considers the rest as an extension.
For example,
File Name.ext
with a tag: 8.1
becomes
File Name [8.1]
1] replaces the extension.
By the way, It's good that the divider ( ; ) is always present, for clarity.
Only dots mess things up...
For example,
File Name.ext
with a tag: 8.1
becomes
File Name [8.1]
1] replaces the extension.
By the way, It's good that the divider ( ; ) is always present, for clarity.
Only dots mess things up...
Re: Append labels (as words) and tags to file names (selected)
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);
}
}
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Heavy! Thank you very much!
Re: Append labels (as words) and tags to file names (selected)
Btw, the original code could be changed to
and should work as well...
Code: Select all
if (!$label && !$tags) { continue; }
else { renameitem("* [$label; $tags].?", $file); }
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
Hello again )
Can this action be reversed?
File Name [this to label; this to tags].ext
Some of the file names contain square braces, but not ; symbol between those braces,
so the script shouldn't be mistaken.
P. S. Ah, this script would require version 18 as well?..
It seems, (more 3D looking) version 14 has some troubles reading tag.dat created by version 18...
Or can I just open the *dat it some text editor, select all except for the version info and copy and paste it into the *dat for version 14?
Can this action be reversed?
File Name [this to label; this to tags].ext
Some of the file names contain square braces, but not ; symbol between those braces,
so the script shouldn't be mistaken.
P. S. Ah, this script would require version 18 as well?..
It seems, (more 3D looking) version 14 has some troubles reading tag.dat created by version 18...
Or can I just open the *dat it some text editor, select all except for the version info and copy and paste it into the *dat for version 14?
Last edited by AugerJ on 16 Jul 2017 16:12, edited 1 time in total.
Re: Append labels (as words) and tags to file names (selected)
Show a few of those names, especially those with additional square brackets
Full names, after the tagging + labeling script renamed the original ones
And by reversed, you mean
that tag + label is created and the [from label; from tag]
is removed from the file name?
Full names, after the tagging + labeling script renamed the original ones
And by reversed, you mean
that tag + label is created and the [from label; from tag]
is removed from the file name?
One of my scripts helped you out? Please donate via Paypal
Re: Append labels (as words) and tags to file names (selected)
[ENG] Iris 1.5 Parody @ SNL Korea [Grey; )].mp4highend wrote:Show a few of those names, especially those with additional square brackets
Full names, after the tagging + labeling script renamed the original ones
No, it should stay.And by reversed, you mean
that tag + label is created and the [from label; from tag]
is removed from the file name?
"Labels" and "tags" in the file names — for another system (e.g. Mac OS)
and "proper" labels and tags — for the current system.
Re: Append labels (as words) and tags to file names (selected)
There are file names like these:
[Fancam] 100522 Sunny SNSD - Intro+Run Devil Run [Grey; distorted heavily].mp4
(10.08.08) Bouquet Ep.03 (Super Junior, Miss A) [ENG SUB] [Grey; )].mp4
[15.09.18] 베스티 - Excuse Me(평촌1번가 문화의거리 축제) by 헤임달 [Grey; ].mp4
or
[15.09.18] 베스티 - Excuse Me[평촌1번가 문화의거리 축제] by 헤임달 [Grey; ].mp4
Examples with square braces:
[60fps]
[4K]
Mostly dates
like [131229]
the fancam word
and
[ENG SUB]
And some names in Korean.
[Fancam] 100522 Sunny SNSD - Intro+Run Devil Run [Grey; distorted heavily].mp4
(10.08.08) Bouquet Ep.03 (Super Junior, Miss A) [ENG SUB] [Grey; )].mp4
[15.09.18] 베스티 - Excuse Me(평촌1번가 문화의거리 축제) by 헤임달 [Grey; ].mp4
or
[15.09.18] 베스티 - Excuse Me[평촌1번가 문화의거리 축제] by 헤임달 [Grey; ].mp4
Examples with square braces:
[60fps]
[4K]
Mostly dates
like [131229]
the fancam word
and
[ENG SUB]
And some names in Korean.
Re: Append labels (as words) and tags to file names (selected)
As long as the square brackets don't contain the semicolon it should work:
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), "^((.+?)\|\|(.+?)){7,}$");
$labels = trim(regexreplace($labels, "\|\|[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)
It works for tags, not for labels.
Re: Append labels (as words) and tags to file names (selected)
Anyway, tags are the important part,
because, if not by running a script,
I can search (Booliean):
Blue;
then select all and assign the label
etc.
It wouldn't take too long.
So, thank you for your help.
because, if not by running a script,
I can search (Booliean):
Blue;
then select all and assign the label
etc.
It wouldn't take too long.
So, thank you for your help.
Re: Append labels (as words) and tags to file names (selected)
Labels are working fine here...
Which XY version?
Show me the file name where a label isn't set
Open your tag.dat file and show me the line
after "Labels:"
Which XY version?
Show me the file name where a label isn't set
Open your tag.dat file and show me the line
after "Labels:"
One of my scripts helped you out? Please donate via Paypal