I am trying to take a bunch of files and turn them into nodes that link to those files in my system. Now when I say a bunch I am talking about thousands, if not tens of thousands of files. So I need a way to do this which includes using multiple directories as the source. Mainly one directory with multiple sub-directories to recurse through.

So I decided to go with the migrate module. In my module setup that creates the migration script I have a schema declared for an intermediary table. This table will hold all of the path information for each file I want to import.

I then (in the install function hook) loop through the image directory recursively and gather a list of file names and paths. Then I stick the information into the intermediary table. This table is what I then import from.

The only problem is that when mapping the file fields I am unable to figure out how to get it to get the source path from each entry. It seems to want me to specify a flat path where all the files will reside and that won't work.

Is there a way to get it to get the full source path from the intermediary table?

This is using Drupal 7 and Migrate 2.2.

Here is the mapping information I am trying. The jpg_uri field is where that source path should be coming from (I just can't seem to figure out how to make that happen).

$jpg_arguments = MigrateFileFieldHandler::arguments('',
  'file_fast', FILE_EXISTS_RENAME, NULL, array('source_field' => 'jpg_name'),
  array('source_field' => 'jpg_filename'), array('source_field' => 'jpg_filename'));

$this->addFieldMapping('field_image', 'jpg_uri')

1 Answer 1


I believe you need to pass NULL as the first argument to arguments() instead of ''.

$jpg_arguments = MigrateFileFieldHandler::arguments(NULL, 'file_fast', ... etc);
  • I tried that and it didn't work.
    – Patrick
    Commented Oct 28, 2011 at 14:51
  • It turns out that this problem was more complex than I thought. But if I put the full path in the intermediary table and used this NULL option then it works.
    – Patrick
    Commented Dec 5, 2011 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.