diff --git a/mm_custom_command.module b/mm_custom_command.module
index 8067501..2ad936f 100644
--- a/mm_custom_command.module
+++ b/mm_custom_command.module
@@ -36,10 +36,16 @@ function mm_custom_command_config($step)  {
     '#description' => t('Define output file.'),
     '#default_value' => $step->settings['output_file'],
   );
+  $form['mm_custom_command_conf']['input_file'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Input file'),
+    '#description' => t('Define input file.'),
+    '#default_value' => $step->settings['input_file'],
+  );
   $form['mm_custom_command_conf']['command'] = array(
     '#type' => 'textfield',
     '#title' => t('Command'),
-    '#description' => t("Define command for this action. If you want to use 'Output file' value from previous field use [output_file]."),
+    '#description' => t("Define command for this action. If you want to use 'Output file' value from previous field use [output_file].  If you want to use 'Input file' value from previous field use [input_file]."),
     '#default_value' => $step->settings['command'],
   );
   if (module_exists('token')) {
@@ -102,17 +108,22 @@ function mm_custom_command_php_config($step) {
 function mm_custom_command_action($step, $file) {
   // replace tokens
   $output_file = token_replace($step->settings['output_file'], 'media_mover_file', $file);
+  $original_output_file = $output_file;
+  $output_file = escapeshellarg($output_file);
+  $input_file = token_replace($step->settings['input_file'], 'media_mover_file', $file);
+  $input_file = escapeshellarg($input_file);
   $command = token_replace($step->settings['command'], 'media_mover_file', $file);
 
   // change [output_file] to value from $output_file
   $command = str_replace('[output_file]', $output_file, $command);
+  $command = str_replace('[input_file]', $input_file, $command);
 
   ob_start();
     passthru($command ." 2>&1", $command_return);
     $command_output = ob_get_contents();
   ob_end_clean();
 
-  return $output_file;
+  return $original_output_file;
 }
 
 /**
