Hi,
Been scanning the forum for some hours and have found some "almost fitting" answers, and been trying for a few days to get it to work, but even with the manual + a regex manual and some earlier experience of using regex (and lot of experience using BRU, one of the very best tools on the entire internet) I just can't seem to get this to work, so I am asking for help.
I have +200000 folders with standardized names in this format: "nnnnnnn (XXXXXX) - zzzzzzz", where:
- "nnnnn" is a string of different length, including spaces, numbers and some special but filename-compatible characters (mostly characters like "ü", "ä", "ö" etc.). There can be any number of folders sharing the same "nnnnnn" (usually between 1-50, not that it matters).
- "(XXXXXX)" is a numeric code with zero-padding enclosed in a space + parenthesis => always in the form of " (" + 6 digits + ") ".
- "zzzzzzz" is a character jumble = any number of filename-compatible characters including space, but always at least 1 character in length, and always with the "- "-prefix (or " - " if you like).
- The "(XXXXXX) - zzzzzz"-combination is unique for every "nnnnnn", but only as a combination (the same "(XXXXXX)" and "- zzzzzz" can occur, but any combination of the two is unique).
All these folders reside in one single "megasuperfolder" (if anyone is interested these are automatically collected and stored movement-triggered wildlife surveillance video snippets on a NAS, just don't ask me why this has been done this way or I might reconsider jumping out the window...).
What I would like to do is go through the entire megafolder and CREATE new folders named "nnnnnn" (for every unique nnnnnn, which IRL is the name of the location of the wildlife cam) and then MOVE all folders and their content that are sharing that same "nnnnnn" INTO the newly created (grouping) folder AND RENAME them in the process by removing the "nnnnnn" (and the following single space) from the moved folders.
Just to be über-clear...
I want to go from a (shit-)load of folders (all containing multiple files) that are named:
qazxswedc dd ttt (123456) - fhh abbetcx/any number of files
qazxswedc dd ttt (444111) - kdjflk ll kkk/any number of files
dhh kkds jjjd (985566) - jhhfdjk i8/any number of files
dhh kkds jjjd (772511) - fhfhfh ggg/any number of files
dhh kkds jjjd (985566) - hatt ttt ttt/any number of files
to a hierarchical 2-tiered folder structure sorted at the upper folder level on the "nnnnnn"-part, with the lower folder level keeping the truncated version "(XXXXXX) - zzzzzz" of the original folder and with all the files being moved with/staying in the new subfolders:
qazxswedc/(123456) - fhh abbetcx/the same any number of files
qazxswedc/(444111) - kdjflk ll kkk/the same any number of files
dhh kkds jjjd/(985566) - jhhfdjk i8/the same any number of files
dhh kkds jjjd/(772511) - fhfhfh ggg/the same any number of files
dhh kkds jjjd/(985566) - hatt ttt ttt/the same any number of files
I know this is doable, but I &%¤#& can't get it to work.
/Mike