I built a simple code that parses all the music folders inside several disks and puts the list in an array.
Folder names begin with a few spaces when they are categories, with one space when they are "destination folders". For instance. see this structure:
[0] => /Volumes/SAMPLES/ VOCALS/ [1] => /Volumes/SAMPLES/ VOCALS/ AFRICA/ [2] => /Volumes/SAMPLES/ VOCALS/ AcmeInc Club Vocals/ [3] => /Volumes/SAMPLES/ VOCALS/ AtomicInc Dance Vocals/ [4] => /Volumes/SAMPLES/ VOCALS/ AFRICA/ AfroInc Zulu Vocals/ [5] => /Volumes/SAMPLES/ VOCALS/ AFRICA/ SampleInc Warriors/ [6] => /Volumes/SAMPLES/ VOCALS/ AFRICA/ SampleInc Warriors/SampleInc_Warriors_Ululation/ [7] => /Volumes/SAMPLES/ VOCALS/ AFRICA/ SampleInc Warriors/SampleInc_Warriors_Drums/
etc. I need to select only the final folders and try several combinations of greedy and non-greedy templates, starting with the final $ For example. the following path does not work:
$pattern = "#\/ ([:alnum:]+?)/$#i"; $matches = preg_grep ($pattern, $root);
Expected Result:
[3] => /Volumes/SAMPLES/ VOCALS/ AcmeInc Club Vocals/ [4] => /Volumes/SAMPLES/ VOCALS/ AtomicInc Dance Vocals/ [5] => /Volumes/SAMPLES/ VOCALS/ AFRICA/ AfroInc Zulu Vocals/ [6] => /Volumes/SAMPLES/ VOCALS/ AFRICA/ SampleInc Warriors/
Instead, I get all the folders, or neither, nor orphans. Please note that special characters, for example, or! may be in the folder name. Thanks for the suggestions, 3 days, tried everything, desperately, thanks!
source share