You can use the del command in Command Prompt (CMD) to delete files using wildcards:
del /Q "directory_path\wildcard_pattern"
In this example, the del command will delete all files that match the wildcard pattern in the specified path without prompting for confirmation.
Note: The /Q
flag specifies quiet mode, which suppresses confirmation prompts.
The following example shows how to use this syntax in practice.
Example: How to Delete Files Using Wildcards in CMD
Suppose that we want to delete all files that start with temp_ in the following path:
C:\Users\admin\Documents\cmd_script\my_demoApp\
We can type the following command to delete the files:
del /Q "C:\Users\admin\Documents\cmd_script\my_demoApp\temp_*"
Output: 👇️
We can see that all files starting with temp_ in C:\Users\admin\Documents\cmd_script\mydemoApp\ are deleted without prompting for confirmation.
Note: Use this command with caution as it will permanently delete all matching files.
Conclusion
I hope the above article on deleting the files using wildcards in CMD is helpful to you.
You can find more topics about Active Directory tools and PowerShell basics on the ActiveDirectoryTools home page.