From df8aaa7e221e833072cf523d90bfe8cd669751e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Thu, 5 Feb 2026 09:30:58 +0100 Subject: [PATCH] [options] add '--restrict-filenames' & '--windows-filenames' --- docs/options.md | 4 ++++ gallery_dl/option.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/options.md b/docs/options.md index 67bf3b1c..c339d788 100644 --- a/docs/options.md +++ b/docs/options.md @@ -24,6 +24,10 @@ ('/O' for "original" filenames) -d, --destination PATH Target location for file downloads -D, --directory PATH Exact location for file downloads + --restrict-filenames VALUE Replace restricted filename characters with + underscores. One of 'windows', 'unix', 'ascii', + 'ascii+', or a custom set of characters + --windows-filenames Force filenames to be Windows-compatible -X, --extractors PATH Load external extractors from PATH --clear-cache MODULE Delete cached login sessions, cookies, etc. for MODULE (ALL to delete everything) diff --git a/gallery_dl/option.py b/gallery_dl/option.py index 7adca7eb..08bbe1bc 100644 --- a/gallery_dl/option.py +++ b/gallery_dl/option.py @@ -268,6 +268,19 @@ def build_parser(): dest="directory", metavar="PATH", help="Exact location for file downloads", ) + general.add_argument( + "--restrict-filenames", + dest="path-restrict", metavar="VALUE", action=ConfigAction, + help=("Replace restricted filename characters with underscores. " + "One of 'windows', 'unix', 'ascii', 'ascii+', " + "or a custom set of characters"), + ) + general.add_argument( + "--windows-filenames", + dest="path-restrict", nargs=0, action=ConfigConstAction, + const="windows", + help="Force filenames to be Windows-compatible", + ) general.add_argument( "-X", "--extractors", dest="extractor_sources", metavar="PATH", action="append",