when a space is found in filename, space is used as datestamp separator instead of underscore

This commit is contained in:
Karl Voit 2017-12-08 13:07:23 +01:00
parent 0bc1cd3428
commit 745e604680

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
PROG_VERSION = u"Time-stamp: <2017-08-26 11:49:23 vk>"
PROG_VERSION = u"Time-stamp: <2017-12-07 15:25:09 karl.voit>"
"""
date2name
@ -161,10 +161,15 @@ def get_converted_basename(matched_pattern, item):
def get_timestamp_from_file(formatstring, item):
"""read out ctime or mtime of file and return new itemname"""
if " " in item:
separator_char = " "
else:
separator_char = "_"
if options.ctime:
return time.strftime(formatstring, time.localtime(os.path.getctime(item))) + "_" + item
return time.strftime(formatstring, time.localtime(os.path.getctime(item))) + separator_char + item
elif options.mtime:
return time.strftime(formatstring, time.localtime(os.path.getmtime(item))) + "_" + item
return time.strftime(formatstring, time.localtime(os.path.getmtime(item))) + separator_char + item
else:
logging.error("internal error: not ctime nor mtime chosen! You can correct this by giving a parameter")