Batch file with "menu" for deleting files referencing path from a text file -


good day all,

please pardon me if question may appear odd. not able pinpoint past examples suit ideal script wish accomplish.

currently, have following script. delete files folders location listed in text file (del_location.txt).

for /f "tokens=*" %%a in (del_location.txt) del \q "%%a"

i did not choose use forfiles, network working on in company @ windows 2000 without ability run forfiles , due security reasons, not able install patches.

there multiple location in del_location.txt , there instances users may not wish delete listed location. hence wondering how write "menu" function, reads off listed location in del_location.txt , echo selection. lets user choose selection in yes/no fashion before commencement of delete sequence? allowing user "walk off" terminal after choosing wants delete.

*also, far can find online, without forfiles, not able choose delete files older n days. right state so?

your , advices appreciated.

you can set each lines in del_location.txt array. since batch don't support array, need manually.

@echo off setlocal enabledelayedexpansion  :main set lines=0  /f "tokens=*" %%a in (del_location.txt) (     set array[!lines!]=%%a     set /a lines+=1     echo !lines!^) %%a )  echo. & echo. set /p choice=which file want delete? ^>  if %choice% lss 1 goto main if %choice% gtr %lines% goto main  set /a choice-=1  del /q !array[%choice%]! echo. & echo. echo "!array[%choice%]!" deleted ^^! echo. & echo. choice /c:yn /m "do want delete more files? [y/n]" /n if %errorlevel% == 1 goto main if %errorlevel% == 2 exit /b 

this script provided delete 1 file per turn. if want batch delete, try modify yourself, ask or me if stuck @ point.

think there's way delete files based on date other forfiles method. btw, dir source /o:d list , sort out files based on date.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -