| 1. |
Solve : Folder Cleaner Utility, Should I include a Log File?? |
|
Answer» I'm developing a command line utility that will remove sub-directories/files BUT leave the parent folder. My question is, should I include the ability to write the deleted sub-directories/files to a log file, so the user could see what was deleted? I'm developing a command line utility that will remove sub-directories/files BUT leave the parent folder. This should do that job: it's untested. Remove the rem to create the log file. Code: [SELECT]@echo off :: removes the files and folders under %1 but leaves the %1 folder set "folder=%~1" if not "%~1"=="" if exist "%folder%\" ( rem DIR "%folder%" /b /s /a-d >file.log pushd "%folder%" && (rd /s /Q /f "%folder%" >nul 2>&1 & popd) ) pause |
|