KToolBox icon indicating copy to clipboard operation
KToolBox copied to clipboard

Add custom attachments directory naming and sequential filename indentation features

Open Copilot opened this issue 5 months ago • 0 comments

This PR implements two highly requested features that enhance file organization and naming flexibility:

🗂️ Feature 1: Custom Attachments Directory Naming

Adds support for customizing the attachments directory name using post properties, similar to how post_dirname_format works for post directories.

New Configuration Option:

KTOOLBOX_JOB__POST_STRUCTURE__ATTACHMENTS_DIRNAME_FORMAT={title}

Example Usage:

# Use post title as attachments folder name
KTOOLBOX_JOB__POST_STRUCTURE__ATTACHMENTS_DIRNAME_FORMAT={title}

# Use post ID and title combined  
KTOOLBOX_JOB__POST_STRUCTURE__ATTACHMENTS_DIRNAME_FORMAT={id}_{title}

# Use published date and title
KTOOLBOX_JOB__POST_STRUCTURE__ATTACHMENTS_DIRNAME_FORMAT={published}_{title}

Result:

Post_Directory/
├─ content.txt
├─ post.json
└─ Title_of_Post/         # Instead of "attachments"
   ├─ 1.jpg
   └─ 2.png

🔢 Feature 2: Sequential Filename Indentation

Adds the ability to preserve original filenames while using sequential numbering, addressing the limitation where sequential_filename=True completely replaced original names.

New Configuration Option:

KTOOLBOX_JOB__SEQUENTIAL_FILENAME_INDENTATION=True

Comparison:

  • Without indentation: 1.png, 2.jpg, 3.gif
  • With indentation: 1_OriginalImage.png, 2_PhotoFile.jpg, 3_Animation.gif

🔧 Implementation Details

  • Backward Compatible: All existing functionality preserved, new features are opt-in
  • Integrates Seamlessly: Works with existing features like sequential_filename_excludes, filename_format, etc.
  • Minimal Changes: Surgical modifications following the codebase patterns
  • Comprehensive Testing: 15 new test cases covering various scenarios and edge cases
  • Full Documentation: Updated FAQ, configuration guide, and auto-generated reference docs

🧪 Testing

All tests pass including:

  • 8 test cases for custom attachments directory naming
  • 7 test cases for sequential filename indentation
  • All existing functionality regression tests
  • Live demo showing features working individually and together

📖 Documentation

  • Added FAQ entries with detailed examples and use cases
  • Updated configuration guide with practical examples
  • Enhanced docstrings for auto-generated reference documentation

Both features address real user needs for better file organization and naming flexibility, while maintaining the simplicity and reliability that KToolBox users expect.

Fixes #350.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Sep 17 '25 08:09 Copilot