24

I'm trying out Node Export for mass node export, but it seems that I have to choose every node to export individually.

What if I want to export all nodes of a selected content type? Is there any way I can do this in Node Export, or I should find another module?

4 Answers 4

26

You can do it with drush:

$ drush help ne-export
Export nodes using Node export.

Arguments:
  nids : A list of space-separated node IDs to export.

Options:
  --file : The filename of the output file.  If supplied, the node code will be
exported to that file, otherwise it will export to stdout.
  --format : If supplied, node code will be output using a particular export
format, if available. (e.g. serialize)
  --status : Filter for 'status'; A boolean value (0 or 1) indicating whether
the node is published (visible to non-administrators).
  --promote : Filter for 'promote'; A boolean value (0 or 1) indicating whether
the node should be displayed on the front page.
  --sticky : Filter for 'sticky'; A boolean value (0 or 1) indicating whether
the node should be displayed at the top of lists in which it appears.
  --translate : Filter for 'translate'; A boolean value (0 or 1) indicating
whether the node translation needs to be updated.
  --language : Filter for 'language'; The language code (e.g. de or en-US) of
this node.
  --type : Filter for 'type'; The machine-readable name (e.g. story or page) of
the type of this node.
  --sql : Filter by SQL (EXPERIMENTAL); An SQL query string that returns nids
(e.g. "SELECT nid FROM nodes WHERE nid < 10").
  --code : Filter by PHP code (EXPERIMENTAL); PHP code that prints or returns,
an array or CSV string of nids (e.g. "custom_get_my_nids();"). Don't include PHP
tags.

For example,

drush ne-export --type=article --file=article.txt

will output all of the article nodes to article.txt in serialized format. You can then use drush to import them:

$ drush help ne-import
Import nodes previously exported with Node export.

Arguments:

Options:
  --uid : User ID of user to save nodes as. If not given will use the user with
an ID of 1. You may specify 0 for the Anonymous user.
  --file : The filename of the input file.  If supplied, the node code will be
imported from that file, otherwise it will import to stdin.

For example:

drush ne-import --uid=1 --file=article.txt

*updated

8
  • Thanks, but is this suitable for large amount of nodes (> 1000) ?
    – Codium
    Aug 29, 2012 at 13:19
  • In theory, yes, if you give PHP enough memory and set a pretty high execution time. I think the last time I did this I had hundreds of nodes, maybe close to a thousand.
    – mpdonadio
    Aug 29, 2012 at 13:21
  • Thanks again. Here is more info drupal.org/node/1681584. I'll try Views Data Export too
    – Codium
    Aug 29, 2012 at 13:23
  • 1
    where the result exported file stored on the harddisk when using Drush command ?
    – Ahmad Zain
    Apr 14, 2014 at 9:54
  • 2
    @AhmadZain The output is stored wherever you specify it to do. The above command should store the file in the same place you ran the command from.
    – mpdonadio
    Apr 14, 2014 at 15:22
5

You could go to the list of all content in Drupal's admin pages ( /admin/content in D7), then filter by content type, then select all, then select 'Node export' from the dropdown menu

4
  • 2
    Yes! This is the answer I have been looking for. This is a lot easier than having to install and configure Views Bulk Operations (VBO). For such a simple solution, it was really hard to find.
    – Magmatic
    Aug 13, 2015 at 15:46
  • 1
    That only exports the current page of content of that type, not ALL the content of type. Mar 10, 2016 at 11:14
  • then select 'Node export' from the dropdown menu what menu?
    – Ejaz
    May 5, 2016 at 14:18
  • it may answer that last question. I also was not seeing this till i disabled the admin_views_node View which had been turned on for that site, and cleared caches. now in the Update Options dropdown at admin/content, i see an option to 'node export'. Alternatively, if i have that View enabled, I can edit it, select the Bulk Operations field and add the 'node export' operation. Jun 26, 2016 at 22:03
0

You can use Node export module for above mentioned purpose. It says:

It allows users to export nodes and then import it into another Drupal installation, or on the same site. Using this module you can save yourself a lot of time setting up new websites that have similar nodes to websites you've already made, migrating nodes to new Drupal versions, or between development/staging/production sites.

0

This might help you in dividing the results. Simple bash script:

#!/bin/bash
# Run this script in Drupal root app directory!
# Requirements: drush command tool installed with ne-export command (you need Node Export module installed in Drupal)

maxRows=100
startFrom=0
for i in {0..17}
do
  startFrom=$(( (i)*100 ))
  echo "SELECT nid FROM node where node.type='noticia' limit $startFrom,$maxRows" # just for debugging
  drush ne-export  --file="nodes-exported/nodes-exported-$i.json" --format='json' --sql="SELECT nid FROM node where node.type='noticia' limit $startFrom,$maxRows" # of course set your own SQL here
done

exit 0

Your Answer

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

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