diff --git a/potx.drush.inc b/potx.drush.inc
new file mode 100644
index 0000000..207b096
--- /dev/null
+++ b/potx.drush.inc
@@ -0,0 +1,150 @@
+<?php
+
+/**
+ * @file
+ *   Translation template extractor module drush integration.
+ */
+
+/**
+ * Implements hook_drush_command().
+ *
+ * @see drush_parse_command() for a list of recognized keys.
+ *
+ * @return
+ *   An associative array describing our command.
+ */
+function potx_drush_command() {
+  $items['potx'] = array(
+    'callback' => 'potx_drush_extract',
+    'description' => 'Extract translatable strings from Drupal source code.',
+    'arguments' => array(
+      'mode' => 'potx output mode e.g. single or multiple',
+    ),
+    'options' => array(
+      'modules' => 'Comma delimited list of modules to extract translatable strings from.',
+      'files' => 'Comma delimited list of files to extract translatable strings from.',
+      'folder' => 'Folder where the translation extraction is done. If no other option is set this defaults to the current directory.',
+      'api' => 'Drupal core version to use for extraction settings.',
+    ),
+    'examples' => array(
+      'potx single' => 'Extract translatable strings from applicable files in current directory and write to single output file',
+      'potx multiple --modules=example' => 'Extract translatable strings from applicable files of example module and write to module-specific output file.',
+      'potx --files=sites/all/modules/example/example.module' => 'Extract translatable strings from example.module and write to single output file.',
+      'potx single --api=8 --folder=projects/drupal/8' => 'Extract strings from folder projects/drupal/8 using API version 8.',
+    ),
+  );
+  return $items;
+}
+
+/**
+ * Implementation of hook_drush_help().
+ *
+ * This function is called whenever a drush user calls
+ * 'drush help potx'.
+ *
+ * @param
+ *   A string with the help section (prepended with 'drush:').
+ *
+ * @return
+ *   A string with the help text for our command.
+ */
+function potx_drush_help($section) {
+  if ($section == 'drush:potx') {
+    $help = dt('Generates translation templates from the given Drupal source code in the current working directory.');
+    $help .= "\n\n". dt('Possible potx modes are:');
+    $help .= "\n". dt(' single    Single file output mode, every file folded into the single output file (default).');
+    $help .= "\n". dt(' multiple  Multiple file output mode, .info files folded into module .pot files.');
+    $help .= "\n\n". dt('If no files are specified, potx will autodiscover files from the current working directory. You can specify concrete files to look at to limit the scope of the operation.');
+    return $help;
+  }
+}
+
+/**
+ * Drush command callback.
+ */
+function potx_drush_extract($mode = 'single') {
+  // Include library.
+  include_once(dirname(__FILE__) . '/potx.inc');
+  global $_potx_strings;
+
+  // Get Drush options.
+  $modules_option = drush_get_option('modules');
+  $files_option = drush_get_option('files');
+  $folder_option = drush_get_option('folder');
+  $api_option = drush_get_option('api');
+  if (empty($api_option) || !in_array($api_option, array(5, 6, 7, 8))) {
+    $api_option = POTX_API_CURRENT;
+  }
+
+  if (!empty($modules_option)) {
+    $modules = explode(',', $modules_option);
+    foreach ($modules as $module) {
+      $output = '';
+      $files = potx_parser_source_files(drupal_get_path('module', $module), '*', $api_option, TRUE);
+
+      // Parse strings, collect output and write file for current module.
+      foreach ($files as $file) {
+        drush_print("Processing $file...");
+        $split = explode(DIRECTORY_SEPARATOR, $file);
+        $file_name = array_pop($split);
+        potx_parser_parse_file($file, $file_name, 'potx_parser_callback_save_string', 'potx_parser_callback_version', $api_option);
+        $output .= potx_parser_build_output(POTX_STRING_RUNTIME, 'potx_parser_callback_save_string', 'potx_parser_callback_version', NULL);
+      }
+      potx_drush_write_file($module . '.pot', $output);
+      drush_print('File ' . $module . '.pot written');
+      $_potx_strings = array();
+    }
+    drush_print("Done.");
+    return;
+  }
+  elseif (!empty($files_option)) {
+    $files = explode(',', $files_option);
+  }
+  elseif (!empty($folder_option)) {
+    $files = potx_parser_source_files($folder_option, '*', $api_option, TRUE);
+  }
+  else {
+    // No file list provided so autodiscover files in current directory.
+    $files = potx_parser_source_files(drush_cwd(), '*', $api_option, TRUE);
+  }
+
+  $output = '';
+  foreach ($files as $file) {
+    drush_print("Processing $file...");
+    $split = explode(DIRECTORY_SEPARATOR, $file);
+    $file_name = array_pop($split);
+    potx_parser_parse_file($file, $file_name, 'potx_parser_callback_save_string', 'potx_parser_callback_version', $api_option);
+    if (count($_potx_strings) > 0) {
+      if ($mode == 'single') {
+        $output = potx_parser_build_output(POTX_STRING_RUNTIME, 'potx_parser_callback_save_string', 'potx_parser_callback_version', 'potx_parser_callback_header');
+        potx_drush_write_file(drush_cwd() . '/' . str_replace('.', '-', preg_replace('![/]?([a-zA-Z_0-9]*/)*!', '', $file_name)) .'.pot', $output);
+        drush_print('File ' . drush_cwd() . '/' . str_replace('.', '-', preg_replace('![/]?([a-zA-Z_0-9]*/)*!', '', $file_name)) .'.pot written');
+      }
+      elseif ($mode == 'multiple') {
+        $output .= potx_parser_build_output(POTX_STRING_RUNTIME, 'potx_parser_callback_save_string', 'potx_parser_callback_version');
+      }
+      $_potx_strings = array();
+    }
+  }
+
+  if ($mode == 'multiple') {
+    potx_drush_write_file(drush_cwd() . '/' . basename(drush_cwd()) . '_' . date('mdY') . '.pot', $output);
+    drush_print('File ' . drush_cwd() . '/' . basename(drush_cwd()) . '_' . date('mdY') . '.pot written');
+  }
+
+  drush_print("Done.");
+}
+
+/**
+ * Writes a file with given strings.
+ *
+ * @param string $file_name
+ *   Target file name.
+ * @param string $output
+ *   The string that will be written in the file.
+ */
+function potx_drush_write_file($file_name, $output) {
+  $fp = fopen($file_name, 'w');
+  $fw = fwrite($fp, $output);
+  $fc = fclose($fp);
+}
diff --git a/potx.inc b/potx.inc
index 9f3351a..16a973b 100644
--- a/potx.inc
+++ b/potx.inc
@@ -300,15 +300,16 @@ function potx_parser_parse_file($file_path, $display_name = '', $string_save_cal
  * @param $api_version
  *   Drupal API version to work with.
  */
-function potx_parser_build_output($string_mode = POTX_STRING_RUNTIME,  $string_save_callback = 'potx_parser_callback_save_string', $file_version_callback = 'potx_parser_callback_version', $header_callback = 'potx_parser_callback_header', $template_export_langcode = NULL, $translation_export_langcode = NULL, $api_version = POTX_API_CURRENT) {
+function potx_parser_build_output($string_mode = POTX_STRING_RUNTIME,  $string_save_callback = 'potx_parser_callback_save_string', $file_version_callback = 'potx_parser_callback_version', $header_callback = NULL, $template_export_langcode = NULL, $translation_export_langcode = NULL, $api_version = POTX_API_CURRENT) {
 
   // Initialize storage for .po file output.
   $data = array(
-    'header'  => $header_callback($template_export_langcode, $api_version),
     'sources' => array(),
     'strings' => '',
   );
 
+  $data['header'] = (!empty($header_callback) && function_exists($header_callback)) ? $header_callback($template_export_langcode, $api_version) : '';
+
   // Get strings and versions by reference.
   $strings  = $string_save_callback(NULL, NULL, NULL, 0, $string_mode);
   $versions = $file_version_callback();
@@ -1092,6 +1093,7 @@ function potx_parser_callback_save_string($value = NULL, $context = NULL, $displ
     return ($string_mode == POTX_STRING_RUNTIME ? $_potx_strings : $_potx_install);
   }
 }
+
 /**
  * Returns a header generated for a given file.
  *
