How to Delete Batch Files of a Folder but Not Subfolders

It's pretty much everything in the title, really. I do have a 'root' folder with a lot of documents in it, and I want to empty it every evening, but I don't wish to destroy the subfolders it contains.

Best Answered by

Dany· Answered on Feb 03, 2023

Although it's not difficult to create a folder and subfolders, you definitely don't want to do so until you really have to if you already have a complicated directory structure that took effort to design. You can fairly quickly replicate a folder structure while ignoring the files within, but you may also choose to remove all the files from a folder while keeping the subfolder structure you've built. You are free to choose between the two approaches. This guide will show you how to use straightforward CMD command lines to remove files while keeping directories.

Unless you're deleting data from the root of the C disk, you don't require administrator access for this. You need to boot Command Prompt Windows 10 and type in del *.* /s /q. It is a simple command, isn't it? All files in this folder will be deleted, and subfolders within it will be contained by this command. Make sure you first make a backup of the files because the delete operation does not send the contents to the Recycle bin.

If you accidentally deleted some critical files and you cannot find them in the Recycle bin, here is a perfect tool that can help you a lot – EaseUS Data Recovery Wizard. Personal photos, favorite films, music, and videos can quickly be recovered with this safe tool. There are only three simple steps to retrieve the deleted files from your PC or laptop: scan the target disk/partition, filter and select the files, and recover the files.

Use EaseUS Data Recovery Wizard to recover deleted or lost files easily and quickly.

Tutorials on how to recover lost, deleted, or formatted data from HDD, SSD, USB, SD card, or other storage media on Windows and Mac.

People Also Ask

Use Shell Script to Delete the Files from Directory Based on Date Parameter

You can use a Shell script to delete the files from the directory based on the date parameter, but it is risky and easy to lose essential files. We will show you how to delete these files older than 2000 on your computer.


Jan 19, 2023

How to Recover Deleted Items with Windows File Recovery

Some files you cannot recover from the Recycle Bin can be recovered with third-party data recovery software or Windows File Recovery. Keep reading to learn the details.


Jan 03, 2023

Is It Impossible to Completely Delete Files from the Computer

When you delete a file from your computer, it does not simply vanish - at least not immediately. The data may be recoverable. This guide will show you how to permanently delete files so they cannot be recovered in Windows 11/10/8/7.


Jan 20, 2023

How to Fix Windows 8.1 System Files Not Accessible on Computer

It looks like your system files are deleted or corrupted. Don't be frustrated. Since you can open CMD, you can fix the problem with the CMD. We will show you how to do that.


Jan 11, 2023

How to Delete Files and Folders with Exclusion Circumstances

Do you want to learn how to remove a file with an exclusion circumstance using PowerShell? Don't panic because this answer will show you how to delete numerous files with the Remove-item cmdlet and delete files that do not match the criteria.


Jan 12, 2023

How to Recover Deleted Files from SD Card Using Chrome OS

SD cards are widely used due to their high data transfer speed and hot-swappable features, although various data loss issues plague them. Don't panic if you accidentally delete files from your SD card; different recovery methods and SD recovery software can help you retrieve deleted files from your SD card.


Dec 29, 2022