\n/', '/\n/', '/wmf2svg<\/desc>\n/' ); $replacement = array( 'xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"', '', '', '' ); /** * ================================================================= * MAIN * ================================================================= */ $processed = 1; $good = 0; $error = 0; $no_maches = 0; $files = glob($path . '*.svg'); print '==================================================' . "\n"; print ' SVG Patcher' . "\n"; print '==================================================' . "\n"; print 'Processing ' . count($files) . ' files.' . "\n"; print '--------------------------------------------------' . "\n"; foreach ( $files as $filename) { print $processed . "\t" . $filename . "\t" . ' - '; $fileContent = file_get_contents($filename); $count = null; $replacedContent = preg_replace($regexExpr, $replacement, $fileContent, -1, $count); if ($count) { if (FALSE !== file_put_contents($filename, $replacedContent)) { print 'Ok'; $good++; } else { print 'Error'; $error++; } } else { print 'No matches'; $no_maches++; } print "\n"; $processed++; } print '--------------------------------------------------' . "\n"; print 'Done.' . "\n"; $processed--; print 'Processed: ' . $processed . "\n"; print 'Patched: ' . $good . "\n"; print 'Failed: ' . $error . "\n"; print 'No matches: ' . $no_maches . "\n"; ?>