Gerhardpet
asked on
Batch file to delete all files and folders
I have this batch file that will delete all files in a folder but it does not delete the folders inside the BVDATA folder
Can any one help? I want to delete all files and folders/files inside sub-folders using a batch file
del "E:\ProgramData\BusinessVision\bv_till\BVDATA\*.*" /F /Q
Can any one help? I want to delete all files and folders/files inside sub-folders using a batch file
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Program Data is a protected folder. Try the script with Run as Administrator.
ASKER
@oBdA - That worked. Thanks!
The ProgramData folder is in the E drive so it is not protected.
The ProgramData folder is in the E drive so it is not protected.
If it is only deleting files and not folders type the command like this:
I removed the *.* and changed it to just *
Give that a try, and run your command prompt as administrator.
del "E:\ProgramData\BusinessVision\bv_till\BVDATA\*" /F /Q
I removed the *.* and changed it to just *
Give that a try, and run your command prompt as administrator.
John Hurst,
"del" only deletes files in the folder specified. If a folder is specified, it will delete files inside that folder.
But it will not delete a folder, which is why two steps are required.
Gerhardpet,
another possibility, if you don't mind deleting the root folder -- which you might if there are special NTFS permissions on it, or if it's shared -- is this:
"del" only deletes files in the folder specified. If a folder is specified, it will delete files inside that folder.
But it will not delete a folder, which is why two steps are required.
Gerhardpet,
another possibility, if you don't mind deleting the root folder -- which you might if there are special NTFS permissions on it, or if it's shared -- is this:
ECHO rd /s /q "E:\ProgramData\BusinessVision\bv_till\BVDATA\*.*"
md "E:\ProgramData\BusinessVision\bv_till\BVDATA