I have a folder C:\Epson Scans, I am trying to figure out how to write a script that will delete the contents of the folder but leave the folder intact. I have figured out how to delete the entire folder and I could recreate it. But I wanted to know if anyone knows a way of just deleting the contents inside the folder and not actually deleting the folder. Any help with this would be greatly appreciated!
Edit: Inserting working code so I can loop through many computers and do it at once. Will someone please tell me why the code is not working where I have inserted it?
@echo off setlocal enabledelayedexpansion set Delete_success=0 set total=0 for /F %%G in (pclist.txt) do ( set /a total+=1 pushd "C:\Epson Scans" || exit /B 1 for /D %%I in ("*") do ( rd /S /Q "%%~I" ) del /Q "*" popd if !ERRORLEVEL!==0 ( set /a Delete_success+=1 ) else ( echo EpsonDelete copy failed on %%G>>EpsonDelete_FailedPCs.txt ) ) echo Delete Success: %Delete_success%/%total% >>EpsonDelete_FileCopy.txt