Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save greggles/842ee2dd34b406b0ac83 to your computer and use it in GitHub Desktop.
Save greggles/842ee2dd34b406b0ac83 to your computer and use it in GitHub Desktop.
Finds Drupal files by name and lists out where they are being used (i.e. what nodes or users are associated with it)
<?php
// Save this, edit it and then...
// Run this with something like drush -v @sitename scr filename.php
// If a file is found and known to be in use, the use will be listed as an array of data.
// Edit the "card-1.xls" part.
$fid = db_query("SELECT fid FROM {file_managed} WHERE filename = 'card-1.xls'")->fetchField();
if ($fid) {
$file = file_load($fid);
var_dump(file_usage_list($file));
}
else {
echo "file not found";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment