Index: bin/php/clusterize.php
===================================================================
--- bin/php/clusterize.php	(revision 22561)
+++ bin/php/clusterize.php	(working copy)
@@ -110,12 +110,12 @@
     }
 }
 
-function copyFilesFromDB( $copyFiles, $copyImages, $remove )
+function copyFilesFromDB( $excludeScopes, $remove )
 {
     global $cli, $dbFileHandler;
 
     $cli->output( "Exporting files from database:");
-    $filePathList = $dbFileHandler->getFileList( !$copyFiles, !$copyImages );
+    $filePathList = $dbFileHandler->getFileList( $excludeScopes, true );
 
     foreach ( $filePathList as $filePath )
     {
@@ -189,7 +189,15 @@
 }
 else
 {
-    copyFilesFromDB( $copyFiles, $copyImages, $remove );
+    $excludeScopes = array();
+    if ( !$copyFiles )
+        $excludeScopes[] = 'binaryfile';
+    if ( !$copyImages )
+        $excludeScopes[] = 'image';
+    if ( !$copyMedia )
+        $excludeScopes[] = 'mediafile';
+
+    copyFilesFromDB( $excludeScopes, $remove );
 }
 
 $script->shutdown();
Index: kernel/classes/clusterfilehandlers/dbbackends/mysql.php
===================================================================
--- kernel/classes/clusterfilehandlers/dbbackends/mysql.php	(revision 22561)
+++ kernel/classes/clusterfilehandlers/dbbackends/mysql.php	(working copy)
@@ -775,20 +775,19 @@
         return true;
     }
 
-    function _getFileList( $skipBinaryFiles, $skipImages )
+    function _getFileList( $scopes = false, $excludeScopes = false )
     {
         $query = 'SELECT name FROM ' . TABLE_METADATA;
 
-        // omit some file types if needed
-        $filters = array();
-        if ( $skipBinaryFiles )
-            $filters[] = "'binaryfile'";
-        if ( $skipImages )
-            $filters[] = "'image'";
-        if ( $filters )
-            $query .= ' WHERE scope NOT IN (' . join( ', ', $filters ) . ')';
+        if ( is_array( $scopes ) && count( $scopes ) > 0 )
+        {
+            $query .= ' WHERE scope ';
+            if ( $excludeScopes )
+                $query .= 'NOT ';
+            $query .= "IN ('" . join( "', '", $contexts ) . "')";
+        }
 
-        $rslt = $this->_query( $query, "_getFileList($skipBinaryFiles, $skipImages)" );
+        $rslt = $this->_query( $query, "_getFileList( array( " . implode( ', ', $scopes ) . " ), $excludeScopes )" );
         if ( !$rslt )
         {
             $this->_error( mysql_error( $this->db ) );
Index: kernel/classes/clusterfilehandlers/ezdbfilehandler.php
===================================================================
--- kernel/classes/clusterfilehandlers/ezdbfilehandler.php	(revision 22561)
+++ kernel/classes/clusterfilehandlers/ezdbfilehandler.php	(working copy)
@@ -1009,13 +1009,16 @@
      * Get list of files stored in database.
      *
      * Used in bin/php/clusterize.php.
+     *
+     * @param array $scopes filter out files that have any of these scopes
+     * @param boolean $excludeScopes if true, filter out files that not have any of the scopes listed in $scopes
      */
-    function getFileList( $skipBinaryFiles = false, $skipImages = false )
+    function getFileList( $scopes = false, $excludeScopes = false )
     {
         eZDebugSetting::writeDebug( 'kernel-clustering',
-                                    sprintf( "db::getFileList( %d, %d )",
-                                              (int) $skipBinaryFiles, (int) $skipImages ) );
-        return $this->backend->_getFileList( $skipBinaryFiles, $skipImages );
+                                    sprintf( "db::getFileList( array( %s ), %d )",
+                                             implode( ', ', $scopes ), (int) $excludeScopes ) );
+        return $this->backend->_getFileList( $scopes, $excludeScopes );
     }
 
     /*!
