protected function moveFiles($extension, $actualDir, $targetDir, $throwExceptionIfNotFound = true)
    {
        if (!is_array($extension)) {
            $extension = (array) $extension;
        }

        $finder = new Finder();
        $finder->files()->in($actualDir);

        foreach ($extension as $ext) {
            $finder->name($ext);
        }

        if (iterator_count($finder) < 1) {
            if (!$throwExceptionIfNotFound) {
                return;
            }

            throw new \Exception(sprintf('There is no files with extensions %s.', implode(', ', $extension)));
        }

        foreach ($finder as $file) {
            $f = new File($file->getRealpath(), true);
            $f->move($targetDir, $file->getFilename());
        }
    }
protected function moveFiles($extension, $actualDir, $targetDir, $throwExceptionIfNotFound = true)
    {
        if (!is_array($extension)) {
            $extension = (array) $extension;
        }

        $finder = new Finder();
        $finder->files()->in($actualDir);

        foreach ($extension as $ext) {
            $finder->name($ext);
        }

        if (iterator_count($finder) < 1) {
            if (!$throwExceptionIfNotFound) {
                return;
            }

            throw new \Exception(sprintf('There is no files with extensions %s.', implode(', ', $extension)));
        }

        foreach ($finder as $file) {
            $f = new File($file->getRealpath(), true);
            $f->move($targetDir, $file->getFilename());
        }
    }
protected function moveFiles ( $ extension , $ actualDir , $ targetDir , $ throwExceptionIfNotFound = true ) { if ( ! is_array ( $ extension ) ) { $ extension = ( array ) $ extension ; } $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ actualDir ) ; foreach ( $ extension as $ ext ) { $ finder -> name ( $ ext ) ; } if ( iterator_count ( $ finder ) < 1 ) { if ( ! $ throwExceptionIfNotFound ) { return ; } throw new \ Exception ( sprintf ( 'There is no files with extensions %s.' , implode ( ', ' , $ extension ) ) ) ; } foreach ( $ finder as $ file ) { $ f = new File ( $ file -> getRealpath ( ) , true ) ; $ f -> move ( $ targetDir , $ file -> getFilename ( ) ) ; } }
Move files of extension type.

@param string|array $extension                 The extensions you need to find
@param string       $actualDir                 Source directory
@param string       $targetDir                 Target directory
@param bool         $throwExceptionIfNotFound Throws an exeption if files are not found

@throws Exception If files are not found
Move files of extension type .