Skip to main content
Bang Logo

Bang File Copier (CLI Tool)


Overview

Bang File Copier is a lightweight command-line tool written in Python that scans a given directory for files whose names start with an exclamation mark (!), then copies those files into one or more predefined destination directories. During the copy process, each file is renamed by prefixing it with the source folder’s name.

I use this tool for my personal photography workflow. After each shoot, I manually review the photos and mark the best ones by adding one or more exclamation marks (!) at the start of the filename. This tool then automates the next step by finding those marked files and copying them into the folders I use for retouching and publishing.

Bang Screenshot


Development Method

This project was developed in an iterative AI-assisted workflow:

  1. I first explained my project goal to an AI tool.
  2. The AI generated a more complete project explanation.
  3. I reviewed and edited that explanation multiple times until it was ready for README.md.
  4. I then asked the AI to generate a step-by-step development plan, which it saved in produce_steps.md.
  5. In my free time, I asked the AI to implement each step progressively.
  6. After each implementation step, I reviewed the generated code and edited it when needed.
  7. Finally, I completed the final fixes and refinements, then updated the README sections.

Tools used in this process:

  • VSCode (editing and project work)
  • ChatGPT (project explanation and documentation drafting)
  • Copilot CLI (code generation and implementation support)

Dependencies

Required

  • Python 3.8+

Optional

  • rich – Pretty console output with tables, panels, and styled text
  • pyfiglet – ASCII art text rendering (used for the intro banner)

Both optional dependencies serve UI enhancement only. The tool will fall back to plain text output if they are unavailable.


Packaging & Installation

Using pyenv + venv keeps your global Python clean and avoids dependency conflicts.

pyenv install 3.11.11   # one-time (if not already installed)
pyenv local 3.11.11
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install bang-file-copier

This installs the latest published version and exposes the bang CLI command.

3. Install from source (development)

Install in editable mode from the project root:

pip install -e .

This installs the dependencies and exposes the bang CLI command from [project.scripts].

4. Run the tool

Use the installed CLI:

bang [path] [--dry-run]

Or run it as a Python module:

python -m bang_file_copier [path] [--dry-run]

Core Features

1. Folder Scanning

  • Accepts a target directory path as input (either explicitly or defaults to the current working directory).

  • Scans only the top-level of the directory (no recursion in v1).

  • Identifies files that:

    • Are regular files (not directories)
    • Have names starting with ! (e.g., !photo1.jpg, !note.txt)

2. File Copying to Two Destinations

  • Copies all matched files into two destination directories.

  • Destination directories are:

    • Read from a configuration file (e.g., config.json or config.yaml)
    • Or fallback to hardcoded defaults if config is missing.

3. File Renaming Strategy

  • Each copied file is renamed using the following format:

    <source_folder_name>_<original_filename>
    
  • Example:

    Source folder:  vacation2026
    Original file: !img01.jpg
    New filename:  vacation2026_!img01.jpg
    
  • (Optional future extension: remove ! from filename after prefixing.)


4. Dry-Run Mode

  • A --dry-run flag simulates all operations without copying any files.

  • In dry-run mode:

    • The tool prints:

      • Which files would be copied
      • Their computed destination paths
      • Their renamed filenames
    • No filesystem writes occur.

    • No log entries are written (unless explicitly enabled with a flag like --log-dry-run).


5. Logging System

5.1 Log File

  • All real (non-dry-run) operations are recorded in a log file, e.g.:

    bang_copier.log
    
  • Each log entry includes:

    • Timestamp
    • Source directory path
    • Destination directory path
    • Original filename
    • New filename
    • Operation status (SUCCESS / SKIPPED / ERROR)
    • Optional error message
  • Example log entry:

    [2026-01-25 20:42:11]
    SOURCE: /photos/vacation2026
    DEST:   /backup/photos
    FILE:   !img01.jpg -> vacation2026_!img01.jpg
    STATUS: SUCCESS
    

CLI Interface

Basic Usage

bang .

Scans the current directory and copies all !-prefixed files.


With Explicit Folder

bang /path/to/source/folder

Dry Run

bang . --dry-run

Custom Config File

bang . --config ./my_config.json

Manage Destinations

The following options allow you to inspect or mutate the list of configured destinations without performing a copy run:

bang --list-dests                 # display current destinations
bang --add-dest /path/to/dir      # append a destination
bang --remove-dest /path/to/dir   # remove a specific destination
bang --clear-dests                # delete all destinations

List destinations:

List destinations

Add destination:

Add destination

Remove destination:

Remove destination

Clear destinations:

Clear destinations

(These flags are mutually exclusive and exit immediately after performing the action.)


Configuration File (Example: config.json)

{
  "destinations": [
    "/mnt/backup/photos",
    "/mnt/cloud/photos"
  ],
  "log_file": "./bang_copier.log",
  "remove_bang_prefix": false,
  "scan_recursively": false
}

Error Handling Rules

Scenario Behavior
Source folder does not exist Exit with error message
No ! files found Print info message and exit gracefully
Destination folder missing Auto-create (optional flag-controlled)
Destination file already exists Skip + log as SKIPPED
Permission denied Log ERROR and continue with next file
Invalid config file Print error and fall back to defaults

Exit Codes

Code Meaning
0 All operations successful
1 Partial failure (some errors)
2 Fatal error (nothing executed)

Future Enhancements

Potential future additions:

  • GUI interface
  • Recursive directory scanning (--recursive)
  • File deletion after copy (--delete-after-copy)
  • File type filtering (--only-ext .jpg,.png)
  • Parallel copy
  • Remove bang prefix in output names (--remove-bang)
  • JSON log output (--json-log)
  • Stats summary output (--stats)
  • Undo last run (--undo-last-run)

Metadata

Release files for bang-file-copier 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bang-file-copier 1.0.1
File Size Uploaded Provenance
bang_file_copier-1.0.1.tar.gz 14.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bang-file-copier 1.0.1
File Interpreter ABI Platform
bang_file_copier-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.9 kB

Release files / bang_file_copier-1.0.1.tar.gz

Download URL bang_file_copier-1.0.1.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e7bfab33521f2620985d702d13bbbed42a5fa81441327fe3a102a5622d6817da
BLAKE2b-256 checksum
How to use checksums
ea6d690c570ee1abcad1c7481e281208ac737e20426f3a37f6a3331776160878
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Release files / bang_file_copier-1.0.1-py3-none-any.whl

Download URL bang_file_copier-1.0.1-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a38dbfa315369b255b5a1d7ee9278e3a4026d8cfc977523a7e7deec6bb69eef4
BLAKE2b-256 checksum
How to use checksums
1f6b86ce1c1b2f02a44aaf98db6af24897543548deb598757e9035eaa45ae3d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.0

Security for bang-file-copier 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page