Import files into nodes

Events happening in the community are now at Drupal community events on www.drupal.org.
axe312's picture

Hi,
i need to import a bunch of files and create a node for each one. The file should be added into a cck-filefield and the nodetitle sould be created out of the filename. Additionally I should be able to select some taxonomy terms for all nodes.

Simple task, but there is no module which can do that!

So I wrote one (link below), but before I commit it to the CVS, I just want to start a discussion about the module and its features.

Supported Features

  • file is added to a choosen cck field
  • Import files form a folder on the server
  • filter files with regex
  • Create node title out of filename
  • Taxonomy support (Select default values for all nodes)
  • files can be deleted after import
  • the import works ^^

Planned Features

  • CCK Support (Select default values for all nodes)
  • import profiles to reuse the import settings
  • zip-archive upload
  • YOUR IDEA

U can find my module here: http://axe312.de/files/files2nodes.tar.gz
Feel free to test it. Its just an alpha-version, but in my case it allready worked perfectly :)

When this discussion results in a CVS commit, I can support the module as co-maintainer, but iam to busy to be the main-maintainer.

greetings,
axe312

ps.: i hope my english is understandable :)

Comments

Did you check out Migrate?

wapnik's picture

Did you check out Migrate?

How about Node Import...?

arpieb's picture

http://drupal.org/project/node_import

Just tested it for your use case, and it does exactly what you described above... I created a content type, added a FileField to it, uploaded the files to the field's storage path (per node_import's instructions), and mapped the CSV file's filename column to both the node title and FileField. Worked like a charm... No need to re-invent the wheel.

I've also used node_import to load ~3000 Image nodes in one batch before, so I know it supports large sets of file data pretty well.

NOTE: the 6.x-1.0-rc4 version is almost two years old - the dev version is what everyone pretty much uses as that's where the latest features have been implemented. Not sure why an RC5 has never been cut...? I use this module at least once every few weeks to load a site's content from a client's spreadsheets, and it's pretty stable for a "dev" release.

--EDIT--

I also forgot to address the taxonomy question - node_import supports flat AND hierarchical vocabularies (1+ terms), and can even create the terms on the fly if they don't exist. I loaded a parts catalog up once that had ~4 levels of hierarchy, worked like a charm. Only caveat is that if node_import is creating the terms on the fly, you need to have the import rows sorted so the parent terms for any child terms are already created:

Fruits
Fruits>>Citrus
Fruits>>Citrus>>Orange

if you have something like below loading into a hierarchical vocabulary and the terms don't already exist, it will break with "term does not exist" errors for the first row:

Fruits>>Citrus>>Orange
Fruits
Fruits>>Citrus

NOTE: Term and hierarchy delimiters are configurable per-field.

but what should i do when i

axe312's picture

but what should i do when i dont have any cvs files? just the files in the folder uploaded by the other site admins // other tools!?

Use shell tools

rfay's picture

cd my_file_dir
ls >somefile.cvs

There are oh-so-many ways to do this.

Check out the Feeds module

pvhee's picture

Check out the Feeds module for this purpose: http://drupal.org/project/feeds. It can (with contributed modules) import from CSV, TSV, XML, RSS... into the Node system of Drupal, Drupal users, Drupal Commerce entities, taxonomies etc.

Contributed Module Ideas

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: