symfony: [Finder] exclude and/or notPath not working
symfony 5
<?php
use Symfony\Component\Finder\Finder;
require_once getenv()['APPDATA'] . '/Composer/vendor/autoload.php';
$finder = new Finder();
$finder->files();
$finder->in('C:\Users\flip111\Videos\test2');
// $finder->exclude('C:\Users\flip111\Videos\test2\subdir'); // uncomment this
// $finder->notPath('C:\Users\flip111\Videos\test2\subdir'); // or this
$files = iterator_to_array($finder);
foreach ($files as $file) {
dump($file->getRealPath());
}
result
^ "C:\Users\flip111\Videos\test2\49 default.mkv"
^ "C:\Users\flip111\Videos\test2\50 default.mkv"
^ "C:\Users\flip111\Videos\test2\subdir\51 default.mkv"
expected result
^ "C:\Users\flip111\Videos\test2\49 default.mkv"
^ "C:\Users\flip111\Videos\test2\50 default.mkv"
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (11 by maintainers)
Hi, I have the exact situation described above. Multiple
->in(...)
directories and I want to exclude only some folders in some of those locations, which may exist on others (if specified as relative).Having a
notAbsolute
orexcludeAbsolute
or something similar would definitely help. Could this issue be re-opened?