From 745e60468080469ed14c569ee1c8b638788376e6 Mon Sep 17 00:00:00 2001 From: Karl Voit Date: Fri, 8 Dec 2017 13:07:23 +0100 Subject: [PATCH] when a space is found in filename, space is used as datestamp separator instead of underscore --- date2name | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/date2name b/date2name index d148460..390d77d 100755 --- a/date2name +++ b/date2name @@ -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")