Closed patricksan closed 7 years ago
@patricksan A few folks have asked about this. The ability to define what the folder structure is would be nice. The folder names can't have reserved characters though.
You may want /%location%/%date%
in addition to just wanting different date formats.
I think something to the effect of defining the format string like so:
FILENAME_FORMAT = "/{exif.date:%Y-%m-%d}/{exif.location}"
I don't know that I see a problem with putting reserved (i.e. path separator) characters in. Some may want a slightly different folder structure. Here are some I can think of off the top of my head:
/{date:%Y-%d-%b}/{location}/{filename}
/{date:%Y-%m-%d}/{location}/{filename}
/{location}/{date:%Y-%m-%d}/{filename}
/{date:%Y}/{date:%m}/{date:%d}/{filename}
@waynew I like that format and I think it's something we can easily parse.
There are some considerations to keep in mind though. Right now, for example, the leaf folder can be either a location name or an album name. If the album exists in EXIF that takes precedent over location.
I think we want to keep that level of customization included when we try to solve this.
Sketching an idea out, would it make sense to have this in config.ini
?
[Directory]
key=%Y-%m-%d
Then, in filesystem.py
from configparser import ConfigParser
__DIR__ = None
def get_dir():
global __DIR__
if __DIR__ is not None:
return __DIR__
config_file = '%s/config.ini' % constants.application_directory
if not path.exists(config_file):
return None
config = ConfigParser()
config.read(config_file)
if('Directory' not in config.sections()):
return None
__DIR__ = config.get('Directory', 'dir')
return __DIR__
Which would then allow you to do
time.strftime(__DIR__, time_obj)
and path.append(time.strftime(__DIR__, metadata['date_taken']))
I'm happy to write a PR if that looks suitable? Of course, it only lets you set a date based path, so no good if you want /place/date
or anything like that.
PR looks great. Moving discussion there.
PR merged. You can now customize the folder path as documented here. https://github.com/jmathai/elodie#create-your-own-folder-structure
Customizing the file name is being tracked in #107.
I would like to use another format for date like dd/MM/yyyy