Skip to content

Commit c6532a3

Browse files
author
lachlan-00
committed
add -df option to specify your own date format
1 parent 787c767 commit c6532a3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

classifier/classifier.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ def __init__(self):
7070
self.parser.add_argument("-dt", "--date", action='store_true',
7171
help="Organize files by creation date")
7272

73-
self.args = self.parser.parse_args()
73+
self.parser.add_argument("-df", "--dateformat", type=str,
74+
help="set the date format using YYYY, MM or DD")
7475

76+
self.args = self.parser.parse_args()
77+
self.dateformat = 'YYYY-MM-DD'
7578
self.formats = {}
7679
self.dirconf = None
7780
self.checkconfig()
@@ -213,7 +216,10 @@ def main(self):
213216
self.dirconf = os.path.join(os.getcwd(), DIRCONFFILE)
214217

215218
if self.args.date:
216-
self.classify_by_date('YYYY-MM-DD', output, directory)
219+
if self.args.dateformat:
220+
self.classify_by_date(self.args.dateformat, output, directory)
221+
else:
222+
self.classify_by_date(self.dateformat, output, directory)
217223
elif os.path.isfile(self.dirconf):
218224
print('Found config in current directory')
219225
if self.args.output:

0 commit comments

Comments
 (0)