From 736e68ad1f6353a5904da4ed05d8e55266fe6d09 Mon Sep 17 00:00:00 2001 From: Sergio Berlotto Date: Thu, 4 Dec 2014 14:20:56 -0200 Subject: [PATCH 1/2] Remove special and null bytes from the string for convert correctly --- src/sortphotos.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sortphotos.py b/src/sortphotos.py index b811bfae..1851a1e2 100644 --- a/src/sortphotos.py +++ b/src/sortphotos.py @@ -42,9 +42,9 @@ def parse_date_exif(date_string): date_entries = elements[0].split(':') # ['YYYY', 'MM', 'DD'] if len(date_entries) == 3 and date_entries[0] > '0000': - year = int(date_entries[0]) - month = int(date_entries[1]) - day = int(date_entries[2]) + year = int(date_entries[0].strip(' \n\r\t\0')) + month = int(date_entries[1].strip(' \n\r\t\0')) + day = int(date_entries[2].strip(' \n\r\t\0')) else: return None From 4c664be9260faa694ac7caf465b1028072887df5 Mon Sep 17 00:00:00 2001 From: Sergio Berlotto Date: Thu, 4 Dec 2014 14:26:51 -0200 Subject: [PATCH 2/2] Change 'copy' as default to be more secure, added -m --move parameter --- src/sortphotos.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sortphotos.py b/src/sortphotos.py index 1851a1e2..db19e9e7 100644 --- a/src/sortphotos.py +++ b/src/sortphotos.py @@ -407,7 +407,7 @@ def sortPhotos(src_dir, dest_dir, sort_format, rename_format, recursive=False, parser.add_argument('src_dir', type=str, help='source directory') parser.add_argument('dest_dir', type=str, help='destination directory') parser.add_argument('-r', '--recursive', action='store_true', help='search src_dir recursively') - parser.add_argument('-c', '--copy', action='store_true', help='copy files instead of move') + parser.add_argument('-m', '--move', action='store_true', help='move files instead of copy') parser.add_argument('-s', '--silent', action='store_true', help='don\'t display parsing details.') parser.add_argument('-t', '--test', action='store_true', help='run a test. files will not be moved/copied\ninstead you will just a list of would happen') parser.add_argument('--sort', type=str, default='%Y/%m-%b', @@ -447,6 +447,6 @@ def sortPhotos(src_dir, dest_dir, sort_format, rename_format, recursive=False, args = parser.parse_args() sortPhotos(args.src_dir, args.dest_dir, args.sort, args.rename, args.recursive, - args.copy, args.test, not args.keep_duplicates, args.day_begins, + not args.move, args.test, not args.keep_duplicates, args.day_begins, args.ignore_groups, args.ignore_tags, args.use_only_groups, args.use_only_tags, not args.silent)