Skip to main content

Deletes files (hardcore mode - Windows only)

Project description

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

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

hcdel-0.10.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

hcdel-0.10-py3-none-any.whl (1.0 MB view details)

Uploaded Python 3

File details

Details for the file hcdel-0.10.tar.gz.

File metadata

  • Download URL: hcdel-0.10.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for hcdel-0.10.tar.gz
Algorithm Hash digest
SHA256 0e34159db406b1bb8e88af239f21125492bf2b17d8e7619a5c12338e027d0cff
MD5 cc2b3e90a3998f28ff94e191ca7008cf
BLAKE2b-256 9819bd32bfc5a09cdaaaba07a914ddc8914fb937f843a8e2b3b78b2c692cf8e2

See more details on using hashes here.

File details

Details for the file hcdel-0.10-py3-none-any.whl.

File metadata

  • Download URL: hcdel-0.10-py3-none-any.whl
  • Upload date:
  • Size: 1.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for hcdel-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 13b837b1126b57159808632868478ebdf7e935c0889605f9981e10a73c637d0b
MD5 35d0a544e590cb5f111503dba4f1095c
BLAKE2b-256 cd6a261d16e77dbf368b59d0dffa5d65cb669d2106276a37bd2c7e597e646f14

See more details on using hashes here.

Supported by

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