|
Answer» What I need is a batch file that can delete CERTAIN folders when given ANSWERS to certain questions.
Example: I have folders named a to z within another folder. I want the batch file to ask which I want, so I type a. The batch file then removes all other folders, leaving me with only a. Is this possible to ACCOMPLISH using batch? It sounds complicated to me but it may not be, I know a little batch but not much.This code is generic to check the first letter of each folder.
Code: [Select]@echo off setlocal enabledelayedexpansion set /p var=Enter Folder Letter To Keep: for /f "tokens=* delims=" %%i in ('dir /a:d /b foldername') do ( set FNAME=%%i set ltr=!fname:~0,1! if /i !ltr! NEQ %var% rd %%i /s /q )
Change foldername to something appropriate for your system.
Thanks for that, I'll give it a shot. I may end up posting back needing modifications, I deliberately didn't give the full picture because I want to learn how to do as much as possible myself, and there's a lot I need to accomplish with this batch file.
|