Change values of nested fields with entity_metadata_wrapper The background of this question is that I'm trying to migrate data from Drupal 6 Imagefield Extended to Drupal 7 File Entity (with File Entity Inline). See also https://www.drupal.org/node/974888

First I tried to understand how entities work and how they can be extracted and manipulated using Entity Metadata Wrappers. That seems to work ok, for example, I can get the values of my imagefield like this:

$nid = 103025;
$node_wrapper = entity_metadata_wrapper('node', $nid);
$images = $node_wrapper-&gt;field_image-&gt;value();


And it seems that I could change the values of the images with something like this:

// Do something with $images
$node_wrapper-&gt;field_image-&gt;set($images);
$node_wrapper-&gt;revision-&gt;set(1);
$node_wrapper-&gt;save();


(For some reason it's not saving the values for the node in my case, but that's another question.)

My problem now is that I have nested fields, i.e. the imagefield has "subfields" for the source and license (that I had added in Drupal 6 using Imagefield Extended). I do get the values of those nested fields in $images - but only in the typical array with $images[und][0]['value'] and $images[und][0]['safe_value']. But there seems to be no way to get those values through the wrapper, for example like

$node_wrapper-&gt;field_image-&gt;field_source-&gt;value();
$node_wrapper-&gt;field_image-&gt;value()-&gt;field_source-&gt;value();


Now I have been trying for hours to figure out how I can change (or populate) those (sub) fields and then save the entire node, but to no avail.

I'm also wondering if it's necessary to do this on a node level as files are also entities, but it seems that there is nothing like entity_metadata_wrapper('file', $fid);.

I'd appreciate any hint that could point me in the right direction because the search has been kind of exhausting.
Using what Clive mentioned and with the hint eikes provided, this seems to be a way to accomplish what I want:

$nid = 108501;
$node_wrapper = entity_metadata_wrapper('node', $nid);

for ($i = 0; $i &lt; count($node_wrapper-&gt;field_image-&gt;value()); $i++) {
  $node_wrapper-&gt;field_image[$i]-&gt;file-&gt;field_source-&gt;set('NEW SOURCE');
  $node_wrapper-&gt;field_image[$i]-&gt;file-&gt;field_license-&gt;set('NEW LICENSE');
  $node_wrapper-&gt;field_image[$i]-&gt;file-&gt;save();
}

// Just for dev: Check if the values have been saved
$node_wrapper = entity_metadata_wrapper('node', $nid);
dsm($node_wrapper-&gt;field_bild-&gt;value());


Erroneously I used the save() call on the whole node wrapper, but as files are their own entities, the call needs to be on the file, as eikes suggested.

Additionally, I noticed that calling $node_wrapper = entity_metadata_wrapper('node', $nid); after the above code doesn't reflect the changes (for checking). It seems I need to reload the entity first.

Thanks a lot to both of you!