Hubbry Logo
Del (command)Del (command)Main
Open search
Del (command)
Community hub
Del (command)
logo
8 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Del (command)
Del (command)
from Wikipedia
del / erase
DevelopersDEC, Microware, Microsoft, IBM, DR, Datalight, Novell, JP Software, ReactOS Contributors
Operating systemRT-11, OS/8, RSX-11, OpenVMS, DOS, OS-9, MSX-DOS, FlexOS, SISNE plus, OS/2, Windows, ReactOS, KolibriOS, SymbOS, DexOS
PlatformCross-platform
TypeCommand

In computing, del (or erase) is a command in command-line interpreters (shells) such as COMMAND.COM, cmd.exe, 4DOS, NDOS, 4OS2, 4NT and Windows PowerShell. It is used to delete one or more files or directories from a file system.

Implementations

[edit]

The command is available for various operating systems including DOS, Microware OS-9,[1] IBM OS/2,[2] Microsoft Windows[3] and ReactOS.[4] It is analogous to the Unix rm command and to the Stratus OpenVOS delete_file and delete_dircommands.[5]

DEC RT-11,[6] OS/8,[7] RSX-11,[8] and OpenVMS[9] also provide the delete command which can be contracted to del. AmigaDOS[10] and TSC FLEX[11] provide a delete command as well.

The erase command is supported by Tim Paterson's SCP 86-DOS.[12] On MS-DOS, the command is available in versions 1 and later.[13] It is also available in the open-source MS-DOS emulator DOSBox.

Datalight ROM-DOS also includes an implementation of the del and erase commands.[14]

While Digital Research DR-DOS supports del and erase as well, it also supports the shorthand form era, which derived from CP/M. In addition to this, the DR-DOS command processor also supports delq/eraq. These are shorthand forms for the del/era/erase command with an assumed /Q parameter (for 'Query') given as well.[15]

THEOS/OASIS[16] and FlexOS[17] provide only the erase command.

In PowerShell, del and erase are predefined command aliases for the Remove-Item cmdlet which basically serves the same purpose.

Syntax

[edit]
>del filename
>erase filename

See also

[edit]

References

[edit]

Further reading

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The del command is a built-in command-line in and Windows operating systems designed to delete one or more specified files from the , functioning identically to the erase command. Originating in early versions of , it has been a core internal command across all subsequent Windows releases, including through , and is also available in the Windows Recovery Console for limited in system directories. The command supports wildcard characters such as * and ? to target multiple files efficiently, and includes options like /p for prompting confirmation before deletion, /f to force removal of read-only files, /s to recursively delete files in subdirectories, /q for quiet operation without prompts, and /a to filter files by attributes (e.g., read-only or hidden). Files deleted using del are permanently removed and cannot be recovered through standard means, bypassing the Recycle Bin. Its syntax, del [/p] [/f] [/s] [/q] [/a[:]<attributes>] <filenames>, provides flexibility for scripting and batch operations in command-line environments.

Overview

Purpose and Functionality

The del command is a command-line utility in Microsoft Windows operating systems designed to permanently delete one or more files from a specified directory or path. It serves as a fundamental tool for file management, enabling users to remove unwanted or obsolete files directly through text-based interfaces without relying on graphical user interfaces. The del command performs identical actions to the erase command and is used for efficient file removal in batch operations or scripts. At its core, the del command removes the file data from the storage device, rendering the files inaccessible through standard file explorers or applications. This deletion is immediate and irreversible, as the files are not moved to the Recycle Bin or any equivalent trash folder, distinguishing it sharply from graphical deletion methods where recovery is often possible. By targeting files based on their names, paths, or patterns (such as wildcards), del streamlines the process of clearing disk space or maintaining organized storage in environments where is essential. The command primarily affects files and does not directly delete directories, though certain variants or combined usage with other tools can extend its scope. It operates by marking the file's space as available on the disk, which can lead to data overwriting if not handled carefully, emphasizing its role as a basic yet powerful tool for text-based file management. This functionality makes del indispensable for system administrators and power users performing routine maintenance in command-line sessions.

Availability Across Systems

The del command is a fundamental utility available across various operating systems, particularly those rooted in the DOS lineage and compatible environments. It originated in Microsoft's version 1.0, released in 1981, where it functions as an internal command for removing files from the . This command persists in modern Microsoft ecosystems, including the Windows Command Prompt (), where it supports deleting one or more files with options for confirmation and recursion. IBM's operating system incorporates del as part of its command-line interface, enabling file deletion in a manner compatible with DOS conventions. Similarly, the open-source project implements del (also aliased as erase) to ensure compatibility with command-line behaviors. DOS variants, such as developed by (later ), include del as a standard internal command for file management tasks. The command also appears in specialized and historical contexts. Embedded systems like ROM-DOS, a compact DOS-compatible OS from Datalight, provide del for deleting specified files or sets of files in resource-constrained environments. Digital Equipment Corporation's RT-11, a real-time OS for PDP-11 minicomputers, features a DELETE command for removing files from devices or queues. Although analogous to the Unix rm command in purpose, del is native to command shells derived from CP/M, such as those in DOS-based systems, where it evolved from earlier erasure utilities like CP/M's ERA. The following table summarizes key implementations, highlighting developers, supported operating systems, and the command's type:
DeveloperOperating SystemType
(version 1.0, 1981)Internal command
Windows (cmd.exe)Internal command
IBM/Command-line utility
ReactOS ProjectInternal command
Digital Research/NovellInternal command
DatalightROM-DOSInternal command
RT-11DELETE command

History

Origins in Early Operating Systems

The del command traces its origins to the ERASE command in , a pioneering developed by at in the mid-1970s, which provided a foundational model for file management in early microcomputer environments. 's ERASE utility allowed users to remove files from disk directories using simple text-based syntax, supporting wildcard characters for batch operations and reflecting the era's emphasis on efficient command-line interactions. This command was integral to 's widespread adoption on and Z80-based systems starting in 1974, influencing subsequent operating systems designed for limited hardware resources. The command first appeared in a form recognizable to modern users in , developed by at Seattle Computer Products in 1980 as a CP/M-compatible OS for the processor. In , the functionality was provided via the ERASE command rather than "del," enabling file deletion in the system's command interpreter while maintaining compatibility with workflows. This version served as the direct predecessor to , with being licensed by later that year and rebranded. Integration into mainstream personal computing occurred with 1.0 in 1981, jointly developed by and released by as PC-DOS for the PC, where both "del" and "erase" were introduced as synonymous internal commands within . adapted the command from and to support the PC's (FAT) system, marking its adoption in the burgeoning PC ecosystem. Concurrently, similar deletion utilities existed in early DEC systems, such as RT-11 (introduced in 1973 for PDP-11 minicomputers), which used a DELETE command for removing files in its monitor environment. Designed for text-based file management in resource-constrained environments like 8-bit and early 16-bit microcomputers, the del command (and its predecessors) enabled quick deletions without requiring graphical interfaces, which were infeasible due to hardware limitations such as limited RAM and slow storage. Early implementations, including those in and 1.0, often lacked per-file confirmation prompts—prompting only for wildcard operations involving multiple files—potentially leading to accidental in command-line sessions. These features were influenced by mainframe utilities from systems like DEC's, prioritizing simplicity and speed over safeguards in operator-driven workflows.

Evolution in Microsoft Ecosystems

The del command originated as a core utility in , where it was retained unchanged from version 1.0 through the final standalone release, 6.22, in 1994, providing basic functionality within the limitations of the file system and 8.3 filename conventions. With the introduction of in 1993, transitioned to the cmd.exe shell, which enhanced the del command's wildcard support by handling internally rather than relying on external expansion, enabling more precise and flexible operations like recursive deletions across subdirectories without the quirks of the older interpreter. Beginning with in 1995, the del command adapted to support long filenames introduced via the VFAT file system extension, allowing users to delete files by specifying their full names in quotes, while the Windows NT lineage simultaneously integrated compatibility with volumes for secure, journaled file operations. This evolution continued into batch scripting, where features like the /Q quiet mode—added in the Windows NT cmd.exe—suppressed confirmation prompts for wildcard deletions, streamlining automated scripts and reducing interactive overhead in enterprise environments. In 2006, with the release of Windows PowerShell 1.0, Microsoft introduced the Remove-Item cmdlet as the preferred method for file deletion, assigning del as an alias to maintain backward compatibility for scripts and users transitioning from cmd.exe, though del itself remained fully functional in the legacy shell. Subsequent updates in Windows 10 (2015) and Windows 11 (2021) improved Unicode handling in cmd.exe, enabling del to process filenames with international characters via UTF-8 code page (chcp 65001), addressing globalization needs without altering the command's core syntax. As of 2025, the del command shows no signs of major in ecosystems, continuing to be documented and supported in cmd.exe and Windows Recovery Environment, though encourages graphical alternatives like or for routine tasks to enhance user safety and accessibility.

Syntax and Parameters

Basic Syntax

The basic syntax of the del command in the Windows Command Prompt is del [drive:][path]filename, where the optional [drive:] specifies the drive letter (such as C:), [path] indicates the directory path, and filename is the name of the file or files to delete. This command also accepts erase as an alias, performing identical operations with the syntax erase [drive:][path]filename. The target filename can include wildcards like * or ? to match multiple files, but the core structure remains focused on specifying one or more file identifiers. The target parameter defines the file path to delete; if the drive or path is omitted, the command defaults to the current . For instance, entering del filename.txt targets the file in the present directory, while del C:\example\file.txt specifies a full path on drive C:. This flexibility allows targeting files across drives and subdirectories without changing the current location. In DOS and Windows environments, the del command is case-insensitive, meaning DEL file.txt, del file.txt, or DeL file.txt all execute equivalently. It supports drive letters in the standard format (e.g., C:\file.txt) and processes one or more specified filenames sequentially; if deletion fails for one file due to an error such as permissions or non-existence, the command continues with the remaining targets without halting the entire operation. Optional switches, such as those for confirmation or force deletion, can modify this behavior but are not part of the fundamental syntax.

Common Options and Switches

The del command in Windows supports several switches to modify its deletion behavior, allowing users to control prompting, force operations, subdirectory inclusion, and attribute-based selection. These switches are optional and can be combined in the command line following the basic syntax of del [switches] <filename(s)>. Common switches include /P, which prompts the user for confirmation before deleting each file, enabling safer interactive use by requiring a "Y" response to proceed. The /F switch forces the deletion of read-only files by overriding their attributes. /S extends the operation to delete specified files in the current directory and all subdirectories, displaying the names of deleted files unless suppressed. /Q enables quiet mode, suppressing all confirmation prompts to allow non-interactive batch deletions. Additionally, the /A switch targets files based on specific attributes, such as /A:R to delete only read-only files, /A:H for hidden files, or combinations like /A:RA for both read-only and archived files; attributes are specified after a colon without spaces. The command inherently supports wildcard characters in filenames, such as *.* to match all files in the current directory or *.txt for text files, facilitating bulk operations. Switches are case-insensitive (e.g., /p or /P) and their order is independent, except that filenames or wildcards must appear last. To view available options, users can invoke /? at the command prompt, which displays detailed help syntax and parameter descriptions. In scripting contexts, the del command sets the %ERRORLEVEL% to 0 upon successful completion or a non-zero value for errors, such as file not found, allowing conditional logic in batch files.

Usage Examples

Deleting Single Files

The del command in the Windows Command Prompt allows users to remove a single specified file from the , providing a straightforward method for targeted without affecting other files or directories. To delete a file located in the current , the basic syntax is del filename, where filename is the name of the target file including its extension. For instance, executing del example.txt will permanently remove the file example.txt if it exists in the current directory, bypassing the Recycle Bin. When the file is not in the current directory, users must provide the full path to locate and delete it accurately. For example, del C:\temp\report.doc deletes the file report.doc from the C:\temp directory, ensuring the command targets the precise location without ambiguity. This approach is essential for files stored on different drives or subdirectories, as the command operates relative to the specified path. If the specified file does not exist, the del command outputs an such as "Could not find ", indicating the operation failed without proceeding further, and by default, it does not prompt for before attempting deletion. This basic error feedback helps users verify file names and paths quickly during manual cleanup tasks. The command's simplicity makes it ideal for precise, one-off file removals in scenarios like clearing temporary documents or correcting minor file clutter, though options like /p for prompting or /f for forcing deletion of read-only files can be added for additional control as detailed in the syntax section.

Handling Multiple Files and Wildcards

The del command supports deleting multiple files in a single invocation by specifying a list of filenames or using wildcard patterns in the <names> , allowing for efficient batch operations on file sets that match specified criteria. For instance, to remove specific files like file1.txt and file2.txt from the current directory, the command del file1.txt file2.txt processes the arguments sequentially from left to right, deleting each matching file in order without additional prompts unless the /p switch is enabled. Wildcards enable pattern-based deletions for broader scalability, where * matches zero or more characters in a or extension, and ? matches exactly one character. An example is del *.tmp, which removes all files with the .tmp extension in the current directory, such as temporary files generated by applications. To extend this to subdirectories, the /s switch is used, as in del /s *.tmp, which recursively deletes matching files from the current directory and all nested folders. Certain files, such as hidden or files, are excluded by default and require the /a switch with attribute selectors to include them; for hidden files, /a:h targets those with the hidden attribute, while /a:s applies to files. Paths containing spaces must be enclosed in double quotes to avoid errors, for example, del "My Documents\*.doc" deletes all .doc files in the "" directory. These features build on single-file deletion by enabling targeted bulk removal while maintaining control over scope and attributes.

Implementations and Variations

In DOS and Windows Command Prompt

In MS-DOS, the del command provides basic functionality for permanently deleting one or more files from the current directory or specified path, without any integration with a recycle bin or recovery mechanism, meaning deleted files cannot be easily recovered. It supports the traditional convention, limiting names to eight characters for the base name and three for the extension, and allows wildcards like *.* for pattern matching. To delete read-only files, users must first remove the read-only attribute using the attrib -r command before invoking del, as no dedicated force option exists in MS-DOS versions. The command prompts for confirmation when using global wildcards unless suppressed in batch contexts, and it operates directly on the without subdirectory unless combined with other tools. In the Windows Command Prompt (), the del command retains the core logic from for permanent , bypassing the Recycle Bin and performing direct removal from the NTFS or FAT file systems. It extends support to long filenames beyond the 8.3 limit, enabling deletion of files with extended paths up to 260 characters (or more with enabling policies), while still allowing 8.3 short names for compatibility. Key enhancements include the /F switch to force deletion of read-only files without prior attribute changes, introduced in and carried forward, and the /A to select files based on specific attributes such as read-only (/a:r), hidden (/a:h), or system (/a:s). The del command maintains strong compatibility with batch files (.bat) in both and Windows environments, where it can be scripted for automated deletion tasks and interacts seamlessly with environment variables like %CD% to reference the current directory dynamically. For example, a batch script might use del /q "%CD%\temp\*.*" to quietly remove all files in a temporary subdirectory without prompts. As of , released in , the command's syntax and behavior remain unchanged from prior versions, though it can now be executed within the host or via PowerShell's compatibility layer for emulation.

In Other Operating Systems and Shells

In , the del command is extended with DELQ and ERAQ variants that enable a query mode, prompting the user before deletion similar to the /P switch in the implementation but as dedicated commands. This addition provides a for interactive file removal in environments requiring confirmation for batch operations. In contrast to the standard DOS behavior, these options integrate directly into the command name without additional parameters. The OS/9 operating system includes a del command for that operates within its hierarchical (HFM) filesystem, which organizes data into fixed-size sectors and supports multi-user access but prohibits direct deletion of non-empty directories to prevent orphaning file entries. This filesystem-specific constraint ensures , differing from simpler FAT-based systems by requiring directories to be emptied via attr or ddir commands prior to removal. ReactOS implements the del command in a manner that exactly mirrors the Windows Command Prompt version, supporting identical syntax for file and wildcard deletions to maintain binary compatibility with Windows applications. Meanwhile, OpenVMS uses the DCL DELETE command to delete one or more files, supporting wildcards and returning status codes for error conditions. For programmatic file deletion, the LIB$DELETE_FILE Run-Time Library intrinsic routine is available. In , the del command accommodates the High Performance File System (HPFS) by preserving or handling extended attributes (EAs) associated with files, such as metadata for Workplace Shell objects, ensuring that deletions do not corrupt linked resources without explicit EA utilities. , as a shell, aliases del to the Remove-Item cmdlet, where the -Force parameter serves as the equivalent to the /F switch in , bypassing read-only attributes and confirmations for forced deletions. As of 2025, KolibriOS uses the 'rm' command in its shell for file deletion, derived from Unix-like commands but functioning in its lightweight command-line interface for basic file removal on FAT filesystems without modern extensions. SymbOS, a multitasking OS for Z80-based retro hardware, similarly incorporates a del command in its CP/M-compatible shell for deleting files across emulated drives, preserving 1980s-era behaviors. Linux lacks a native del command, favoring rm for deletions, though DOS environments can be emulated using DOSBox to run del as in original MS-DOS.

Limitations and Best Practices

Error Handling and Prompts

The del command in Windows Command Prompt includes built-in mechanisms to handle potential errors during file deletion, primarily through user prompts and error messages, while maintaining execution flow without built-in undo capabilities. By default, when deleting multiple files using wildcards (such as del *.*), the command prompts the user with "Are you sure (Y/N)?" to confirm the action before proceeding, preventing accidental bulk deletions. This prompt appears specifically for wildcard operations and does not apply to single file deletions unless explicitly enabled. For individual write-protected or read-only files, no default confirmation prompt is issued; instead, the command fails silently unless the /f switch is used to force deletion. To enable more granular control, the /p switch prompts for confirmation on each file with "FileName, Delete (Y/N)?", allowing users to approve (Y), skip (N), or abort (Ctrl+C) individually, which is useful for selective deletions in interactive sessions. Conversely, the /q (quiet) switch suppresses all prompts, enabling non-interactive operation in batch scripts or automation, though this increases the risk of unintended deletions without user intervention. The command provides no functionality, as deletions are permanent once confirmed or forced, emphasizing the need for caution in usage. Common errors are reported via messages without halting the entire process. For instance, attempting to delete a locked file (e.g., one in use by another process) results in an "Access denied" error, and the command continues to the next file if multiple are specified. Similarly, if a specified file does not exist, del displays a "File Not Found" message but sets the %ERRORLEVEL% to 0 and proceeds, treating the absence as a non-fatal condition rather than a failure that would trigger conditional branching (e.g., via ||). This behavior—where %ERRORLEVEL% remains 0 even on individual deletion failures, but 1 only for invalid syntax—means scripts relying on error levels for flow control must incorporate additional checks, such as pre-verifying files with dir.

Security and Safety Considerations

The del command in Windows performs permanent , bypassing the Recycle Bin and rendering files irrecoverable through standard recovery methods unless specialized forensic tools are employed immediately. This irreversibility heightens the risk of unintended , particularly in shared environments such as networked drives or collaborative workspaces, where a single erroneous command can affect multiple users' access to critical files without warning or easy restoration. In enterprise Windows deployments, administrators can mitigate these risks by leveraging to restrict access to the Command Prompt, thereby limiting the use of del and preventing unauthorized or accidental deletions across the organization. Conversely, malicious software often exploits the del command to erase traces of its activity, such as logs or temporary files, complicating detection and forensic analysis in compromised systems. To promote safe usage, it is recommended to employ the /P switch, which prompts for before each deletion, allowing users to verify actions and reduce errors. For enhanced auditing and control, graphical file management tools in Windows Explorer or PowerShell's Remove-Item cmdlet offer built-in previews, logging capabilities, and confirmation options that provide greater visibility than the basic del command. As of 2025, integrating file operations with systems like further safeguards against loss by maintaining historical snapshots, enabling recovery even after deletions; users should also avoid wildcard patterns (e.g., *.*) without prior review to prevent broad, unintended removals.

References

  1. https://wiki.kolibrios.org/wiki/Shell
Add your contribution
Related Hubs
User Avatar
No comments yet.