diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index a0af8634baa..92e58782523 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -4135,7 +4135,7 @@ function migrate_delete_old_files($db, $langs, $conf)
//print ''DOL_DOCUMENT_ROOT.$filetodelete."
\n";
if (preg_match('/\*/', $filetodelete) || file_exists(DOL_DOCUMENT_ROOT.$filetodelete)) {
//print "Process file ".$filetodelete."\n";
- $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, 1, 0, null, true, false); // nophperrors to avoid false positive with asterisk
+ $result = dol_delete_file(DOL_DOCUMENT_ROOT.$filetodelete, 0, (preg_match('/\*/', $filetodelete) ? 1 : 0), 0, null, true, false); // nophperrors to avoid false positive with asterisk
if (!$result) {
$langs->load("errors");
print '