You can use the del command in Command Prompt (CMD) to delete all files in a directory:
del /Q "directory_path\*"
In this example, the del command will delete all files in the specified directory without prompting for confirmation.
Note: Ensure that the path you provide exists and that you have the necessary permissions to delete files in that directory.
The following example shows how to use this syntax in practice.
Example: How to Delete All Files in a Directory in CMD
Suppose that we want to delete all files in the following directory:
C:\Users\admin\Documents\cmd_script\my_demoApp
We can type the following command to delete all files in the directory:
del /Q "C:\Users\admin\Documents\cmd_script\my_demoApp\*"
Output: 👇️
C:\>del /Q "C:\Users\admin\Documents\cmd_script\my_demoApp\*"
C:\>
We can see that all files in C:\Users\admin\Documents\cmd_script\my_demoApp are deleted without prompting for confirmation.
Note: The /Q flag specifies quiet mode, which suppresses confirmation prompts. Use the del command with caution as it will permanently delete all files in the specified directory.
Conclusion
I hope the above tutorial on using the del command in CMD to delete all files in a directory is helpful to you.
You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.