Re: Tags from folder names
Posted: 20 Aug 2012 21:04
1. You have to upgrade your beta version again (to v11.40.0206)
2. I don't add so much user choices
3. Try the new script
Remarks: If you select only one folder, it will let you select all parent folder names and the name of the folder as a tag as well. If you have more items selected, it will only let you selected parent folders from the current path.
2. I don't add so much user choices
3. Try the new script
Remarks: If you select only one folder, it will let you select all parent folder names and the name of the folder as a tag as well. If you have more items selected, it will only let you selected parent folders from the current path.
Code: Select all
/* 19.08.2012, Tag files with their parent (grandparent etc.) folder names
v11.40.0206 or up is required for "getpathcomponent"
::load "<xyscripts>\TagFiles.xys";
*/
end (getinfo("CountSelected") < 1), "No file(s) or folder(s) selected, aborted!";
$i = 1;
$parentFolders = "";
$countFolders = getpathcomponent(<curpath>, "count");
if((getinfo("CountSelected") == 1) AND (exists(<curitem>) == 2)) {
$parentFolders = "<curname>|";
}
while($i < $countFolders) {
$parentFolders = $parentFolders . getpathcomponent(<curpath>, "component", $i +1). "|";
$i++;
}
$tags = inputselect("Select all foldernames that should be used as tags for the current file selection:", $parentFolders, "|", 2); // Let's choose which foldernames should be written as tags
$tags = replace($tags, "|", ",");
end ($tags == ""), "No tag(s) selected, aborted!";
$selectedItems = get("SelectedItemsPathNames", "|");
foreach($item, $selectedItems) {
if(exists($item) == 2) {
$selected = folderreport("files", "r", $item, "r", , "|");
tag $tags, $selected, 1, 0; // Add current tags with selected folder names as (new) tags
} elseif(exists($item) == 1) {
tag $tags, $item, 1, 0; // Add current tags with selected folder names as (new) tags
}
}