Commits

Anonymous committed fd85219

Added --move option to calibre_add_if_missing (move added files to another directory).

  • Participants
  • Parent commits 44a07cb

Comments (0)

Files changed (1)

File src/mekk/calibre/scripts/add_if_missing.py

 
 """
 
-import sys
+import shutil
 import re
 import os.path
 from collections import defaultdict
     parser.add_option("-a", "--author",
                       action="store", type="string", dest="author",
                       help="Force given author name.")
+    parser.add_option("-m", "--move",
+                      action="store", type="string", dest="move",
+                      help="Move source files to given directory after adding them")
     (options, args) = parser.parse_args()
     if not args:
         parser.error("""No file or directory specified. Execute with:
 or
     calibre_add_if_missing  file.name otherfile.name dir.name
 """)
+    if options.move:
+        if not os.path.isdir(options.move):
+            parser.error("Parameter given for --move ('%s') is not a directory!" % options.move)
     return (options, args)
 
 
                            force_title=force_title,
                            force_tags=options.tag,
                            force_author=options.author)
+            if options.move:
+                shutil.move(file_name, options.move)
             added_count += 1
 
     print