From 62d7cb1c456f7e1c451eb657d4a668040f46351b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Wed, 14 Aug 2019 17:57:34 +0200 Subject: [PATCH] minor update --- README.rst | 52 +++++++++++++++++++++++++++++++++++++++++++++++- autoimport/db.py | 3 +++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ed19566..6713739 100644 --- a/README.rst +++ b/README.rst @@ -6,7 +6,57 @@ autoimport What is autoimport? =================== -autoimport is a python3 module and program for importing photos into +``autoimport`` is a python3 module and program for importing photos into a libraries using metadata, namely the name; the date and time of the photo, the digitization and the original; the Model and Make and the Software used to create the photo. + +Usage +===== + +``autoimport`` is used in basically two steps: selecting files to copy/move +and then actually copying and moving the files. By default the selection step +is implicit, but it can be run separately using ``autoimport select``. + +``autoimport --help`` gives a list of all available commands and options. + +Extended Usage +============== + +Persistent Database +------------------- + +It can be quite useful to run the selection and actual operation separately. +For instance, when the actual data is unknow and/or homogenous. To avoid +long search times, the intermediate data should then be stored. +This is done using the ``--storage`` option that specifies a path where +a sqlite3 database containing the data is stored. + +A typical use case is a collection of RAW and JPEG data, which might be quite big:: + + autoimport select images/ --storage=autoimport.db -p jpg --walk + autoimport select images/ --storage=autoimport.db -p dng --walk + +Then the files can be copied using:: + + autoimport copy images/ new_images --storage=autoimport.db + rm autoimport.db + +without having to re-search all files. + +The persistent can also be used to explicitly exclude some files using extra scipts, +by accessing the database directly. This requires some knowledge in sqlite3 (and maybe +python3):: + + autoimport select images/ --storage=autoimport.db -p jpg --walk + + sqlite3 + > .open autoimport.db + > DELETE FROM FILES WHERE Model='Nexus 5X'; + > ^D + + autoimport copy images/ new_images/ --storage=autoimport.db + +This example shows how to remove all images made with the Nexus 5X (a cellphone) from the +files that are copied. + diff --git a/autoimport/db.py b/autoimport/db.py index 31e19f8..b58dc77 100644 --- a/autoimport/db.py +++ b/autoimport/db.py @@ -85,4 +85,7 @@ def get_persistent_db(path): return db if(not os.path.exists(os.path.dirname(path))): raise IOError("path '{}' does not exist".format(os.path.dirname(path))) + db = PersistentDatabase(path) + initialize_database(db) + return db return PersistentDatabase(path)