Page 1 of 1
Batch rename with tags
Posted: 24 Apr 2014 15:25
by ezne
Hello,
is there a way to batch rename files in order to easily append their tags and extra tags into their filenames?
Thank you for any help
Re: Batch rename with tags
Posted: 24 Apr 2014 15:29
by highend
Scripting?...
I'm away for the next 5-6 hours, if no one has written anything when I come back I'll do it.
Re: Batch rename with tags
Posted: 25 Apr 2014 13:24
by highend
If you want to configure the divider (between filename, tag and extag(s))
modify the first line.
Try it with a few testitems first...
Code: Select all
$div = "_"; // Select the divider character
foreach($item, <get SelectedItemsPathNames |>) {
$i = 0;
$exTags = "";
while ($i++ <= 5) {
$exTag = tagitems($i, , $item);
if ($exTag != "") { $exTags = $exTags . $exTag . $div; }
}
$tag = tagitems("tag", , $item);
$exTag = trim($exTags, $div, "R");
rename "b", "*$div$tag$div$exTag", , $item;
}
Re: Batch rename with tags
Posted: 25 Apr 2014 15:38
by ezne
Thank you very much!
It works well, as long as there are no filename illegal characters in tags. Would there be a possibility to substitute any of those characters with a '_' and preserve the rest of the tag?
Re: Batch rename with tags
Posted: 25 Apr 2014 16:05
by highend
Sure.
The pipe symbol doesn't need to be replaced, it isn't allowed in tags by default.
Code: Select all
$div = "_"; // Select the divider character
$legal = "_"; // Select the legal char that replaces illegal characters
foreach($item, <get SelectedItemsPathNames |>) {
$i = 0;
$exTags = "";
while ($i++ <= 5) {
$exTag = tagitems($i, , $item);
if ($exTag != "") { $exTags = $exTags . $exTag . $div; }
}
$tag = tagitems("tag", , $item);
$exTag = trim($exTags, $div, "R");
$fileName = regexreplace("$tag$div$exTag", "[<>:""/\\?*]", "$legal");
rename "b", "*$div$fileName", , $item;
}
Re: Batch rename with tags
Posted: 25 Apr 2014 16:15
by ezne
Sweet! Thank you!
