diff options
Diffstat (limited to 'generate.py')
-rwxr-xr-x | generate.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/generate.py b/generate.py index 49ed27f..22ff18e 100755 --- a/generate.py +++ b/generate.py @@ -7,19 +7,28 @@ # Usage: # ./generate.py -i /mnt/bgstack15/Backups/bgstack15/Images/Photos/camera/2018/ -o /mnt/public/www/gallery/my2018 -n -d2 -x 'October' -s --nr -from argparse import ArgumentParser +from argparse import ArgumentParser, RawDescriptionHelpFormatter from genlib import * -generate_version="2021-01-29a" +generate_version="2021-02-25a" # WORKHERE the if __main__ thing: -parser = ArgumentParser(description="Make symlink forest for images") # epilog="something" +parser = ArgumentParser(description="Make symlink forest for images", + formatter_class=RawDescriptionHelpFormatter, + epilog="""FORMATTING +Format string will be interpreted as a python f-string, so wrap variable +names with curly braces. +Default format is "{Y}/{M}" + + {Y} is 4-digit year + {M} is month (affected by padding) + {D} is day (affected by padding)""") parser.add_argument("-d","--debug",nargs='?', default=0, type=int, choices=range(0,11), help="Set debug level") parser.add_argument("-v","--version", action="version", version="%(prog)s " + generate_version) g_dryrun = parser.add_mutually_exclusive_group() g_dryrun.add_argument("-n","--dryrun", action="store_true", help="Make no changes (default)") g_dryrun.add_argument("-a","--apply", action="store_true", help="Actually make changes") g_zeropad = parser.add_mutually_exclusive_group() -g_zeropad.add_argument("-z","-0","--zeropad",action="store_true", help="Zero pad month directories (default)") +g_zeropad.add_argument("-z","-0","--zeropad",action="store_true", help="Zero pad month and day strings (default)") g_zeropad.add_argument("--nz","--nozeropad","--no-zeropad",action="store_true", help="Do not zero pad") g_action = parser.add_mutually_exclusive_group() g_action.add_argument("-c","--copy", action="store_true", help="Copy files instead of symlinks. Not recommended.") @@ -31,6 +40,7 @@ g_relative.add_argument("--nr","--norelative","--no-relative", action="store_tru parser.add_argument("-i","--indir",required=True) parser.add_argument("-o","--outdir",required=True) parser.add_argument("-x","--exclude",action="append",help="Exclude pathname matches. Can be used multiple times.") +parser.add_argument("-f","--format",action="store",default="{Y}/{M}",help="Subdirectories should follow this pattern. See FORMATTING heading.") # pull useful values out of the argparse entry args = parser.parse_args() @@ -58,6 +68,7 @@ try: except: # no exclusions pass +subdirformat=args.format if debuglevel >= 10: eprint(args) @@ -75,9 +86,10 @@ these_files = limit( ) print("FOUND FILE COUNT:",len(these_files)) -make_YM_forest( +make_forest( outdir, these_files, + subdirformat = subdirformat, action = action, dryrun = dryrun, debuglevel = debuglevel, |