Skip to main content

cwdfast

A high-performance Python C extension providing native, cross-platform filesystem operations. Optimized for recursive directory traversal, bulk file moving, and batch renaming with minimal memory overhead.

Features

  • Cross-Platform: Native support for Windows (Wide Char) and POSIX/Linux/macOS (FS-encoded bytes).
  • High Performance: Written in C with direct OS API calls (FindFirstFileW/opendir), bypassing Python-level iteration overhead.
  • Smart Conflict Resolution: Automatically appends counters (e.g., -1, -2) to filenames during moves to prevent overwrites.
  • Safe Traversal: Skips . and .., ignores reparse points (Windows), and safely handles symlinks (POSIX).

Installation & Building

Save the C code as fastfs.c and create a setup.py:

from setuptools import setup, Extension

module = Extension(
    "cwdfast",
    sources=["cwdfast.c"],
)

setup(
    name="cwdfast",
    version="0.0.1",
    description="Native filesystem operations",
    ext_modules=[module],
)

Build and install:

python setup.py build_ext --inplace
# or
pip install .

Usage Examples

import cwdfast

# 1. Find all .txt and .log files, ignoring 'node_modules'
files = cwdfast.find_files(
    start="/path/to/dir",
    extensions=[".txt", ".log"],
    excluded=["node_modules", ".git"]
)

# 2. Remove all empty directories, ignoring '.git'
deleted_count = cwdfast.remove_empty_dirs(
    start="/path/to/dir",
    excluded=[".git"]
)

# 3. Move multiple files to a destination (auto-resolves name conflicts)
moved_count = cwdfast.move_files(
    files=["/src/file1.txt", "/src/file2.txt"],
    dest_dir="/dest/dir"
)

# 4. Add '.gma' extension to files without an extension
# (Skips files named 'WorkshopDecompressor' by default)
renamed_count = cwdfast.add_extension_to_files_without_format(
    start="/path/to/dir",
    excluded=[".git"],
    skip_name="WorkshopDecompressor",  # Default
    new_ext=".gma"                     # Default
)

API Reference

Function Description Returns
find_files(start, extensions, excluded=None) Recursively finds files matching any extension in the list. list[str] of matched paths
remove_empty_dirs(start, excluded=None) Recursively deletes empty directories. int (number of dirs deleted)
move_files(files, dest_dir) Moves an iterable of file paths to dest_dir. Creates unique names on conflict. int (number of files moved)
add_extension_to_files_without_format(start, excluded=None, skip_name=None, new_ext=None) Recursively appends new_ext to files lacking a dot in their name. int (number of files renamed)

Note: All path arguments accept standard Python strings. The extension handles OS-specific path encoding automatically.

Download files

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

Source Distribution

cwdfast-0.0.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

cwdfast-0.0.1-cp314-cp314-win_amd64.whl (22.2 kB view details)

Uploaded CPython 3.14Windows x86-64

File details

Details for the file cwdfast-0.0.1.tar.gz.

File metadata

  • Download URL: cwdfast-0.0.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for cwdfast-0.0.1.tar.gz
Algorithm Hash digest
SHA256 bf48a3518fa7afc061cd808f90f2c68e90ac366fb43833ca5b9ec597dfada5b4
MD5 b5df6f0b124493d71020d441e7979a75
BLAKE2b-256 cfca15c3d7797b3e8901cf7b76bc1c5102f7333094fdc4e89d974def7b46548d

See more details on using hashes here.

File details

Details for the file cwdfast-0.0.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: cwdfast-0.0.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for cwdfast-0.0.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 09c67f7ad60d83e3e8367fc2d911ab2bf7ae0e1ff518b1a79df69b11e3e213ab
MD5 2311655dc32aee690954368451b1e53c
BLAKE2b-256 4bd899287a57261adfd6466fcf5c8f6384bf2776ea91651c10dfba4379ef5e5b

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