Skip to content

Allow filename templates to create subdirectories#4687

Open
popsiclelmlm wants to merge 3 commits into
flameshot-org:masterfrom
popsiclelmlm:fix/filename-template-subdirectories
Open

Allow filename templates to create subdirectories#4687
popsiclelmlm wants to merge 3 commits into
flameshot-org:masterfrom
popsiclelmlm:fix/filename-template-subdirectories

Conversation

@popsiclelmlm
Copy link
Copy Markdown

@popsiclelmlm popsiclelmlm commented May 15, 2026

Summary

  • preserve literal / characters in filename templates as path separators while still sanitizing slashes produced by strftime specifiers
  • create parent directories for generated filename-template paths when the configured destination is an existing directory

Fixes #510.

Testing

  • git diff --check
  • cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug (fails locally: Qt6 development files are not installed, so Qt6Config.cmake is unavailable)

@popsiclelmlm popsiclelmlm force-pushed the fix/filename-template-subdirectories branch from 937e26a to 27a93be Compare May 15, 2026 04:12
@ElTh0r0
Copy link
Copy Markdown
Contributor

ElTh0r0 commented May 15, 2026

fails locally: Qt6 development files are not installed, so Qt6Config.cmake is unavailable

Thank you for trying fix the mentioned issue, but after reading above statement it seems you didn't test your proposal yourself - and after testing it myself, I must say, that it doesn't properly work 😑

Currently the following is created with the file pattern '%m/%D/%y'
image

For proper fix it must be additionally considered, that the save path is automatically updated with the (new) subfolders as well - this must be prevented:
26

this causes multiple unwanted subfolders after taking more than one screenshot
image

@ElTh0r0
Copy link
Copy Markdown
Contributor

ElTh0r0 commented May 15, 2026

Personally, I like the idea of creating date-based subfolders, but the solution needs to be rethought.

In my opinion, it should not be allowed to use '/' and '\' in file names at all and the workaround with this special character replacement should be completly removed.

res = res.replace(QLatin1String("/"), QStringLiteral(""))

Just my two cents - waiting for further feedback.

@popsiclelmlm
Copy link
Copy Markdown
Author

Thanks for testing and for the detailed screenshots. I pushed a follow-up that keeps the configured save directory unchanged when the user accepts the generated filename, so date-based subfolders from the filename pattern should not be written back into the save path and nested on later screenshots.

I also left the configured path untouched when the save path is fixed. I could only run git diff --check locally; the existing build directory here does not contain a generated Makefile/Ninja file, so I could not run a local Qt build in this workspace.

@ElTh0r0
Copy link
Copy Markdown
Contributor

ElTh0r0 commented May 15, 2026

so I could not run a local Qt build in this workspace.

Thank you for trying to take one part of my considerations into account (my first remark is still broken). However, I won't continue with the testing if you make code changes without testing them yourself first! Please run local tests yourself before pushing further commits.

@popsiclelmlm
Copy link
Copy Markdown
Author

popsiclelmlm commented May 15, 2026

Thanks for the follow-up. I set up the local Qt6 build environment and verified this before pushing another change.

The new commit fixes the remaining %m/%D/%y parsing case: when the configured pattern contains an explicit path separator, slashes produced by strftime expansions are also treated as path separators. Patterns without explicit separators keep the previous behavior of replacing strftime slashes with the fraction slash character.

Local checks run:

  • cmake -S . -B build-local -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/qt
  • cmake --build build-local --target flameshot -j2
  • HOME=$(mktemp -d) build-local/src/flameshot.app/Contents/MacOS/flameshot config --filename %m/%D/%y -> Parsed pattern example: 05/05/15/26/26
  • HOME=$(mktemp -d) build-local/src/flameshot.app/Contents/MacOS/flameshot config --filename %D_%H -> keeps the slash replacement behavior, e.g. 05⁄15⁄26_18
  • git diff --check

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.

Allow sub directory formatting based on existing file name formatting

2 participants