I'd like to incorporate a chunk into a batch file that searches local drives for a directory, let's say \Temp. If the directory only exists on only one drive, then set a variable, like %temploc%, to that drive. If the directory exists on more than one drive, display the drives that contain \Temp and prompt the user to select which directory to use and set the variable to their selection. I have this snippet already: Code: FOR %%a IN ( C D E F G H I J ) DO IF EXIST %%a:\temp\NUL ECHO Temp directory found on %%a which searches the local drives (C through J) and reports the drives that contain the \Temp directory if that helps. Can anybody help with the rest? It seems like it should be pretty straight-forward, but I'm not having much luck.
This should get you started.. untested, DP Code: @echo off & setLocal EnableDELAYedeXpansion title, [ Find TEMP Directory on All Drives ] for %%d in (c d e f g h i j) do ( if exist %%d: (for /f "tokens=* delims= " %%a in ('dir/b/s %%d:\temp 2^>nul') do ( Echo Temp directory found on: "%%a") ) ) pause