Here's an evaluator clause that one can customize to fit its need.
It takes into account the fact that the appearance (display name) of the drives may differ depending on the settings "Preference/Folders/Virtual Folders/This PC".
This setting can take 5 formats:
- Local Drive (C:)
- C:
- C: (Local Drive)
- C: Local Drive
- Local Drive
Obviously the last one can not be used with this script. For each of the other ones, there's a regexp defined in the script. You just have to choose the one that fits your settings and uncomment it, the other ones should be commented. The current settings in the script below matches the first one of the list above.
Then, you will also have to define your groups, and the letters that you want to associate with these groups.
That has to be done in the section that looks like this:
// --- Change the associations below to suit your needs
ArrayPush(groupNames, "1 - System");
ArrayPush(groupLetters, "C");
ArrayPush(groupNames, "2 - Data");
ArrayPush(groupLetters, "BFGIJZ");
For each group you want, you'll need two lines:
- The first one defines the name of the group (just change the
"2 - Data" part in the below example). You can use a number to start if you want to be able to manage the order the groups display (and use the "Sort groups alphabetically ..." option under the evaluator clause in the configuration dialog).
ArrayPush(groupNames, "2 - Data");
- The second one lets you define all the drive letters that will fall into that group:
ArrayPush(groupLetters, "BFGIJZ");
If there are too many groups in the full clause below, comment or remove the unneeded ones (both two lines each time). If you need more, add those two lines as many times as you need and set-up the proper group names (1st line) and the associated drive letters (2nd line).
Full evaluator clause:
// The different regexps matches the different settings for how the drive names appear in 'This PC'
// Uncomment only the one that matches your setup
// ----
// Format: Local Drive (C:)
letter = RegEx(value, ".*\(([A-Z]):\)", "\1", "e");
// Format: C:
//letter = RegEx(value, "([A-Z]):", "\1", "e");
// Format: C: (Local Drive)
//letter = RegEx(value, "([A-Z]): \(.*\)", "\1", "e");
// Format: C: Local Drive
//letter = RegEx(value, "([A-Z]): .*", "\1", "e");
// Format: Local Drive
// Sorry ... no letter, no grouping
// ----
if (letter == "") return "Unknown (no letter)";
//Output("letter ok");
//map = [ "1-System" = "C"; "2-Music" = "ADEKPQ" ];
//Output(DumpVars());
groupNames = ArrayCreate();
groupLetters = ArrayCreate();
// --- Change the associations below to suit your needs
ArrayPush(groupNames, "1 - System");
ArrayPush(groupLetters, "C");
ArrayPush(groupNames, "2 - Data");
ArrayPush(groupLetters, "BFGIJZ");
ArrayPush(groupNames, "3 - Music");
ArrayPush(groupLetters, "ADEKPQ");
ArrayPush(groupNames, "4 - Backups");
ArrayPush(groupLetters, "NOS");
ArrayPush(groupNames, "5 - Shared");
ArrayPush(groupLetters, "VWXY");
ArrayPush(groupNames, "6 - Optical");
ArrayPush(groupLetters, "ML");
ArrayPush(groupNames, "7 - Removable");
ArrayPush(groupLetters, "HNRTU");
// ---
//Output(DumpVars());
if (Len(groupNames) != Len(groupLetters)) {
Output("Arrays for Group names & letters do not have the same size. Checkk the script");
return "Unknown (Script error)";
}
found = false;
group = "";
for (a = 0; a < Len(groupNames); a++) {
gpName = ArrayGet(groupNames, a);
gpLetters = ArrayGet(groupLetters, a);
//Output("Drive=" + letter + " / gpLetters=" + gpLetters + " / gpName=" + gpName);
if (gpLetters ~~ letter) {
found = true;
group = gpName;
break;
}
//Output("Not matching ...");
}
if (found) return group;
return "Uncharted";