Computer Hope

Microsoft => Microsoft DOS => Topic started by: Nexusfactor on January 08, 2016, 10:31:00 AM

Title: Folder Cleaner Utility, Should I include a Log File?
Post by: Nexusfactor on January 08, 2016, 10:31:00 AM
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?

CCleaner, will empty a folder but won't show what files it removed. BleachBit, does show the files/folders it deleted.

Any feedback would be great.
Title: Re: Folder Cleaner Utility, Should I include a Log File?
Post by: Geek-9pm on January 08, 2016, 11:59:15 AM
IMHO, it is always good to have a record of what you did. A log file wail use very little space than the size of the files removed.  :)
Title: Re: Folder Cleaner Utility, Should I include a Log File?
Post by: camerongray on January 08, 2016, 06:41:48 PM
Adding that would be good.  It would also be good for it to show what it is going to delete before it does it!
Title: Re: Folder Cleaner Utility, Should I include a Log File?
Post by: foxidrive on January 09, 2016, 11:10:59 PM
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