Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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.

share|improve this answer
    
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
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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