0

I have a folder with a large amount of files in. I need to migrate this into Drupals file system so I can then reference them in the content.

The ID of the file is the actual name e.g. 1234.jpg

What's the best method of doing this? I think I have the destination method set using MigrateDestinationFile()

I could write a script to create an xml document which defines every file in the folder and then extend the XMLMigration class and use that but it seems a bit overkill? Are there any source methods that would help with this?

1

Drupal manages files on "usage" basis - files imported to it's managed files table but not used by anything will get deleted on next file garbage collector, or what it's official name is, run.

There are modules like Media supposed to act as an owners and browsers for files like that. And this one actually supports both mass import and inserting it to content, too.

This will not, however, assure you predictable ID. Hardly any solution can, as your filesystem don't know about IDs currently used in your file table, and your Drupal don't know about your filesytem. Thus, modules like Node Export only looks for an actual file name in files directory on import, and then create needed file information in system tables, letting other files to get deleted. So, if your need is one-time import, check the docs of a tool you are using for import. It should be covered there.

  • Thanks, I'm now using migrate_extras to set media as my destination which allows me to import the files in. – digital May 21 '13 at 15:42
3

If you are now using migrate_extras to set media as destination, you can take a look to the following links:

  1. An useful example to import images using media as destination
  2. A thread on drupal.org that deals a question very similar to yours

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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