Skip to main content

Deletes files (hardcore mode - Windows only)

Recursive deletion:

The function can recursively delete files and directories, ensuring that all nested files within a given path are removed.

Dry run option (enabled by default!!):

The dryrun argument allows users to preview the files that would be deleted without actually performing the deletion. This can help verify the list of files before proceeding with the actual deletion.

Print files option (enabled by default - can't be disabled when running with dryrun):

The print_files argument enables users to see the files and directories being deleted. This can be useful for logging or providing feedback during the deletion process.

pendmoves.exe to delete everything:

When dealing with stubborn files that cannot be deleted through normal means, PendMoves https://learn.microsoft.com/en-us/sysinternals/downloads/pendmoves helps in cleaning up such files effectively. It ensures that unwanted files are eventually removed (next reboot), preventing them from occupying unnecessary disk space or causing conflicts in the system.

Integration and customization:

The function can be easily integrated into existing scripts or applications. The arguments provide flexibility to customize the deletion process based on specific requirements. A compiled exe file is also available: https://github.com/hansalemaos/hcdel/raw/main/hcdel.exe

In Python

# For security reasons, dryrun is always enabled, and always prints all files that would be deleted!
from hcdel.hcdel import delallfiles
delallfiles(
    path=r'C:\delfiles', dryrun = False, print_files = True
)

# Output 

Deleting: C:\delfiles\xff1fdx.mkv
Deleting: C:\delfiles\xfffdx.mkv
Deleting: C:\delfiles\xfffxxxxxxxdxxx  ddddddddd (2).mkv
Deleting: C:\delfiles\xfffxxxxxxxdxxx  ddddddddd.mkv
Deleting: C:\delfiles\xffxxxxaaxdx.mkv
The following files will be deleted the next reboot: # i kept this file open in my media player 
C:\delfiles\xfffxxxxxxxdxxx  ddddddddd.mkv

CLI

# For security reasons, dryrun is always enabled, and always prints all files that would be deleted!
# https://github.com/hansalemaos/hcdel/raw/main/hcdel.exe

hcdel.exe --path "C:\delfiles" --dryrun 0 --print_files 1

Arguments

delallfiles(
    path: str | None = None, dryrun: int | bool = 1, print_files: int | bool = 1
):
    r"""
    Recursively deletes files and directories.

    Args:
        path (str | None, optional): The path to the directory or file to be deleted. If None or '', the script exits with code 1. Defaults to None.
        dryrun (int | bool, optional): If set to 1 or True, performs a dry run and only prints the files that would be deleted without actually deleting them. If set to 0 or False, deletes the files and directories. Defaults to 1.
        print_files (int | bool, optional): If set to 1 or True, prints the files and directories being deleted. Defaults to 1.

    Returns:
        None

    Raises:
        None

Metadata

Release files for hcdel 0.10

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

Source distribution (sdist)

Source distribution for hcdel 0.10
File Size Uploaded
hcdel-0.10.tar.gz 1.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for hcdel 0.10
File Interpreter ABI Platform
hcdel-0.10-py3-none-any.whl Python 3 none any Details

Total release size: 2.0 MB

Release files / hcdel-0.10.tar.gz

Download URL hcdel-0.10.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
0e34159db406b1bb8e88af239f21125492bf2b17d8e7619a5c12338e027d0cff
BLAKE2b-256 checksum
How to use checksums
9819bd32bfc5a09cdaaaba07a914ddc8914fb937f843a8e2b3b78b2c692cf8e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / hcdel-0.10-py3-none-any.whl

Download URL hcdel-0.10-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
13b837b1126b57159808632868478ebdf7e935c0889605f9981e10a73c637d0b
BLAKE2b-256 checksum
How to use checksums
cd6a261d16e77dbf368b59d0dffa5d65cb669d2106276a37bd2c7e597e646f14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files

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