jebias adlı üyeden alıntı: mesajı görüntüle
Dosya isimlerine göre silmek için;

<?php

$dir1 = new DirectoryIterator(__DIR__ . '/a');
$dir2 = new DirectoryIterator(__DIR__ . '/b');

$files = array();

foreach ($dir2 as $file) {
  $files[] = $file->getFilename();
}

foreach ($dir1 as $file) {
  if ($file->isFile() && in_array($file->getFilename(), $files)) {
    unlink($file->getPathname());
  }
}
çalıştırmadan önceki klasör yapısı;
.
├── a
│** ├── 20.txt
│** ├── 21.txt
│** ├── 22.txt
│** ├── 23.txt
│** ├── 24.txt
│** └── 25.txt
├── b
│** ├── 22.txt
│** ├── 23.txt
│** ├── 24.txt
│** └── 25.txt
└── remove.php

2 directories, 11 files
çalıştırdıktan sonra;
.
├── a
│** ├── 20.txt
│** └── 21.txt
├── b
│** ├── 22.txt
│** ├── 23.txt
│** ├── 24.txt
│** └── 25.txt
└── remove.php

2 directories, 7 files
Dostum süpersin. Canavar gibi çalışıyor.

Yüklü klasörlerde henüz denemedim ama sorun çıkacağını zannetmiyorum.

Çok teşekkür ederim büyük dertten kurtardın