Last active
March 5, 2016 00:17
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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