Skip to main content

Advanced file creator with brace expansion and notification support

Project description

mkfile - Advanced File Creator

A powerful command-line utility for creating blank files with support for brace expansion, automatic directory creation, desktop notifications, and clipboard integration.

Features

  • Brace Expansion: Create multiple files with a single command
  • 📁 Auto Directory Creation: Automatically creates parent directories if they don't exist
  • 📋 Clipboard Integration: Copies absolute file paths to clipboard
  • 🔔 Desktop Notifications: Optional Growl notification support
  • 🖥️ Cross-Platform: Works on Windows, Linux, and macOS
  • 🎯 Smart Parsing: Handles complex patterns with spaces and multiple items

Installation

pip install mkfile

Optional Requirements

  • Python 3.6+
  • Optional dependencies for enhanced features:
pip install clipboard  # For clipboard support
pip install gntp       # For Growl notifications

Usage

Basic Syntax

mkfile [OPTIONS] FILE [FILE ...]

Examples

Create Single File

mkfile test.txt

Create Multiple Files

mkfile file1.txt file2.py file3.js

Create Files with Directory Structure

mkfile src/main.py tests/test_main.py
# Creates: src/ and tests/ directories automatically

Brace Expansion - Simple

mkfile test/{a,b,c}.txt
# Creates: test/a.txt, test/b.txt, test/c.txt

Brace Expansion - Directory Prefix

mkfile dotenv{__init__.py,core.py,utils.py}
# Creates: dotenv/__init__.py, dotenv/core.py, dotenv/utils.py

Brace Expansion - With Spaces (Flexible Syntax)

mkfile src{main.py, utils.py config.py}
# Creates: src/main.py, src/utils.py, src/config.py
# Note: Handles both comma and space separation inside braces

Complex Project Structure

mkfile src/{__init__.py,main.py,utils.py} tests/{__init__.py,test_main.py} README.md setup.py requirements.txt

Real-World Example - Python Package

mkfile mypackage/{__init__.py,core.py,exceptions.py,utils.py} tests/{__init__.py,test_core.py} setup.py pyproject.toml README.md LICENSE requirements.txt .gitignore

Brace Expansion Syntax

Supported Formats

  1. Standard format (recommended):

    mkfile dir/{file1,file2,file3}
    
  2. Directory prefix (no slash):

    mkfile dir{file1,file2,file3}
    # Automatically adds '/' → dir/file1, dir/file2, dir/file3
    
  3. With spaces (flexible):

    mkfile dir{file1, file2, file3}
    mkfile dir{file1 file2 file3}
    # Both work! Splits by comma AND spaces
    
  4. With file extensions:

    mkfile src/{main,utils,config}.py
    # Creates: src/main.py, src/utils.py, src/config.py
    

Brace Expansion Rules

  • Items inside {} can be separated by:
    • Commas: {a,b,c}
    • Spaces: {a b c}
    • Both: {a, b, c} or {a, b c}
  • If prefix doesn't end with / or \, it's treated as a directory name
  • Empty items are skipped
  • Nested braces are not supported

Command-Line Options

--version

Show version information

mkfile --version

--debug

Enable detailed error messages and stack traces

mkfile --debug file1.txt file2.txt

--help

Show help message with examples

mkfile --help

Output

Success

✓ File created: "C:\PROJECTS\myproject\src\main.py"
✓ File created: "C:\PROJECTS\myproject\src\utils.py"

2/2 file(s) created successfully

With Errors

✓ File created: "valid.txt"
✗ Error creating file "invalid/path/file.txt": [Errno 13] Permission denied

1/2 file(s) created successfully

Features in Detail

Automatic Directory Creation

The script automatically creates all parent directories:

mkfile deep/nested/path/to/file.txt
# Creates: deep/ → deep/nested/ → deep/nested/path/ → deep/nested/path/to/

Clipboard Integration

After creating each file, its absolute path is automatically copied to your clipboard (requires clipboard module).

Desktop Notifications

If Growl is installed and running, you'll receive desktop notifications for each file created.

Note: The "Could not initialize Growl" warning is normal if Growl is not running. The script continues to work perfectly without it.

Cross-Platform Paths

The script uses Python's pathlib for cross-platform compatibility. Use forward slashes (/) in commands on all platforms - they'll be converted automatically.

Troubleshooting

"Could not initialize Growl" Warning

This is normal and harmless. It means Growl notification service isn't running. The script works fine without it.

To suppress this warning, you can:

  • Install and run Growl
  • Or ignore it (doesn't affect functionality)

Permission Denied Errors

If you get permission errors:

  • Check directory permissions
  • Run with appropriate privileges
  • Use --debug flag for more details

Files Not Created in Expected Directory

Check your brace expansion syntax:

# WRONG - No directory separator
mkfile mydir{file1,file2}      # Creates: mydir/file1, mydir/file2 ✓

# If you want nested directories, use /
mkfile mydir/{subdir/file1,file2}  # Creates: mydir/subdir/file1, mydir/file2

Tips & Best Practices

  1. Use quotes for files with spaces:

    mkfile "my file.txt"
    
  2. Combine with other commands:

    mkfile src/{main,utils}.py && code src/main.py
    
  3. Create project templates:

    # Save as a shell script
    mkfile project/{src,tests,docs}/{__init__.py} README.md setup.py
    
  4. Verify with tree command:

    mkfile test/{a,b,c}.txt && tree test/
    

Version History

v2.0

  • Added smart brace expansion parsing
  • Auto directory creation
  • Support for space-separated items in braces
  • Improved error handling
  • Better cross-platform support
  • Class-based architecture

v1.0

  • Initial release
  • Basic file creation
  • Growl notifications

License

Free to use and modify.

Contributing

Feel free to submit issues and enhancement requests!


Quick Reference:

# Single file
mkfile file.txt

# Multiple files
mkfile file1 file2 file3

# With directories
mkfile src/main.py tests/test.py

# Brace expansion
mkfile src/{main,utils,config}.py

# Complex structure
mkfile mypackage/{__init__,core,utils}.py tests/{__init__,test_core}.py README.md

Author

Hadi Cahyadi

Buy Me a Coffee

Donate via Ko-fi

Support me on Patreon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkfile-1.0.5.tar.gz (62.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mkfile-1.0.5-cp313-cp313-win_amd64.whl (107.0 kB view details)

Uploaded CPython 3.13Windows x86-64

mkfile-1.0.5-cp312-cp312-win_amd64.whl (107.2 kB view details)

Uploaded CPython 3.12Windows x86-64

mkfile-1.0.5-cp311-cp311-win_amd64.whl (108.0 kB view details)

Uploaded CPython 3.11Windows x86-64

mkfile-1.0.5-cp310-cp310-win_amd64.whl (107.9 kB view details)

Uploaded CPython 3.10Windows x86-64

mkfile-1.0.5-cp39-cp39-win_amd64.whl (116.1 kB view details)

Uploaded CPython 3.9Windows x86-64

File details

Details for the file mkfile-1.0.5.tar.gz.

File metadata

  • Download URL: mkfile-1.0.5.tar.gz
  • Upload date:
  • Size: 62.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mkfile-1.0.5.tar.gz
Algorithm Hash digest
SHA256 9eb7ea2823fcbaeb8271880320a416697eebba43424b7645994d88de6b3871d9
MD5 06907b148ab8605a370de1dfb2a3e030
BLAKE2b-256 915628dee87e37bbe238a6ec58f58db2da0615a2d33e0f2979632970813818bf

See more details on using hashes here.

File details

Details for the file mkfile-1.0.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: mkfile-1.0.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 107.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mkfile-1.0.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 59c8ffc44871f7d92b50ec27a2b6c92bed5119c739e8edf9632245a8b99cf629
MD5 b8f4bf86bd770fea6435e1b0c5ff1e3c
BLAKE2b-256 cc386b88bea010a9e36a66e507002a85544471976826921bab8b5aea4ad9e58a

See more details on using hashes here.

File details

Details for the file mkfile-1.0.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: mkfile-1.0.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 107.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mkfile-1.0.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 532643689644d9d147de448eaef17565aac9fd775d9e251a15895aee99612462
MD5 12de789024e5b11447e0846a56f8c336
BLAKE2b-256 fb8ddc05f5ffe555bead752940c463b6c606e51d65b28efbc69d4e0b7f5b52db

See more details on using hashes here.

File details

Details for the file mkfile-1.0.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: mkfile-1.0.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 108.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mkfile-1.0.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 10193d0483be00d14df166b34b5bc3892bcf4ba4560750f65e0b5c5e499a83d1
MD5 87c6a35e86a6084cc055d324263d8ec1
BLAKE2b-256 a4dace4194ccdaba229abb028ec95bd95ee349f013ed120e733385a33ffecf97

See more details on using hashes here.

File details

Details for the file mkfile-1.0.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: mkfile-1.0.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 107.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mkfile-1.0.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3d3211d17026b3bdd46e28617322f94be2745332d6cdcd7b4f34a32308c30907
MD5 aba43e0404be9bed9434f11c80222e62
BLAKE2b-256 a52cdc7ac9bf45da15951acae1061cb8698c87e2660a86cc3fd27895722156e2

See more details on using hashes here.

File details

Details for the file mkfile-1.0.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: mkfile-1.0.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 116.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mkfile-1.0.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ef0ad96e594c5f78a6405289d86148d6154e647dad580cd7418737655119c2ae
MD5 53e01cdff76a96f6d8cd9047a58316f2
BLAKE2b-256 700c850ce6037b67b70ad52cfeee12d8068fd43d92feda8f7744fb60914693eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page