Skip to content

Instantly share code, notes, and snippets.

@anavarre
Created June 27, 2013 13:17
Show Gist options
  • Save anavarre/5876310 to your computer and use it in GitHub Desktop.
Save anavarre/5876310 to your computer and use it in GitHub Desktop.
Dummy PHP parser to output SQL queries showing which files aren't managed by Drupal
<?php
/**********************************************************************************/
/* Generate a list of filenames to parse in filenames.txt (1 per line) */
/* => running "$ ls -1 > filenames.txt" will output just what you need */
/* */
/* Run the parser.php script from the same directory or change the TXT file path */
/* => Ideally, you just need to run it from the command line: "$ php parser.php" */
/* */
/* Copy/paste the queries that are returned in the MySQL prompt */
/* => MySQL will then return files that are managed by Drupal */
/* => For files that are not managed, MySQL will throw an empty set */
/**********************************************************************************/
DEFINE('FILE', 'filenames.txt');
DEFINE('QUERY', 'SELECT filename FROM file_managed WHERE filename LIKE "%s" AND status=1;');
foreach (file(FILE) as $record) {
printf(QUERY, addslashes(str_replace("\n", '', $record)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment