Skip to content

[options] add --truncate-filenames to trim paths#9079

Open
NecRaul wants to merge 7900 commits intomikf:masterfrom
NecRaul:args/truncate-filenames
Open

[options] add --truncate-filenames to trim paths#9079
NecRaul wants to merge 7900 commits intomikf:masterfrom
NecRaul:args/truncate-filenames

Conversation

@NecRaul
Copy link
Copy Markdown
Contributor

@NecRaul NecRaul commented Feb 17, 2026

This PR introduces a new --truncate-filenames option to automatically truncate filenames so that destination paths stay within OS path-length limits. PathFormat now applies truncation when building filenames and .part files, ensuring compatibility across Windows and POSIX systems.

Changes

  • Add --truncate-filenames CLI argument
  • Read truncate-filenames from the config with default False
  • Update PathFormat.build_path and part_enable to apply truncation
  • Implement _truncate_filename to respect path and name length limits, using os.pathconf on POSIX and fixed limits on Windows

Notes

_truncate_filename currently uses character counts via len(), which may differ from filesystem byte limits for multibyte filenames. Future improvements could make truncation byte-aware for full UTF-8/UTF-16 safety.

mikf and others added 30 commits January 10, 2026 18:08
* bilibili: add support for live photo downloads
* fix: resolve flake8 linting errors (whitespace and line length)
* fix: resolve flake8 E302 and W293 linting errors
* fix: resolve flake8 W293 and E302 linting errors

* simplify syntax
* add 'livephoto' option
* add tests
implement generic access of
* list items        (L[1]   -> L.1)
* dict vslues       (D[key] -> D.key)
* object attributes (O.attr -> O.attr)
in standard format strings
* fix gallery media metadata issues
* retain group/gallery creator
use server invite link that will never expire
mikf#8803 (comment)
to allow disabling the behavior introduced in commit
a79a945
* adding site support for thefap.com
* fixing typo in url tld
* improve & simplify 'model' extractor
* update 'post' extractor
* update docs/supportedsites
* add tests

---------

Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
some instances respond with redirects when using these URLs as is
mikf and others added 28 commits February 12, 2026 19:40
provide '{_path_unc}' and '{_directory_unc}' replacement fields
* feat: extractor for pholder.com
    Closes mikf#2568
* feat[pholder]: support gallery_id properly and tags
* doc[text.nameext_from_name]: minor typo in docstring

* remove '__init__' & 'request' methods and 'json' import
* use 'text.nameext_from_url' to ensure a 'filename' value
* fix 'imgur' links by disabling auto-Referer
* fix 'data["id"].partition()' call
    'partition' returns 3 elements
* use 'item["_source"]' data directly
* remove unused supportedsites overwrite
* catch all exceptions in '_thumb_resolution'
    fixes "KeyError: 'width'"
* use 'author' name for user folders

---------

Co-authored-by: Mike Fährmann <mike_faehrmann@web.de>
- remove 'exception' imports
- replace with 'self.exc'
and prevent "KeyError: 'name'" when accessing the full username
fixes regression introduced in 53cdfaa
Introduce a new --truncate-filenames option to automatically truncate
filenames so that the resulting paths stay within OS path-length limits.
PathFormat now checks this option when building filenames and .part
files, calling _truncate_filename with the directory, filename,
extension, and optional suffix.

- Add --truncate-filenames CLI flag using ConfigConstAction
- Read "truncate-filenames" from config with default False
- Update PathFormat.build_path and part_enable to apply truncation
- Implement _truncate_filename for Windows and POSIX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.