Does node_delete() function deletes the attached media files as well? I'm deleting my 'articles' created before Sat Nov 1 00:00:00 2014 GMT from Drupal 7.34 site, but I'm not sure whether the node_delete() delete the media files as well?

Below is my processing code:

&lt;?php

// Fetch the NIDs of 'articles' created before Sat Nov 1 00:00:00 2014 GMT
$query = db_select('node', 'n')
-&gt;fields('n', array('nid'))
-&gt;condition('type', 'article')
-&gt;condition('created', 1414800000, '&lt;') // 1414800000 = Sat Nov 1 00:00:00 2014 GMT
-&gt;orderBy('created', 'DESC')
-&gt;range(0, 100);
$result = $query-&gt;execute();

// Code to delete my articles in bulk
while ($record = $result-&gt;fetchAssoc()) {
  $nid = $record['nid'];
  echo $nid;
  node_delete($nid);
}

?&gt;
It depends.

If the file has no references left to it in the file_usage table, then yes, it will be deleted.

If there are remaining references, it won't be deleted.

Either way, file_delete() is definitely invoked for the file.