How can i modify this to make it be able to search sub directory’s? i have tried a few different things but i cant seem to crack it?
set /p "folder=Folders Name that the photo's are in: "
setlocal
if "%folder%" == "" call :autodetect1
cls
for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
if exist "%%d:\%folder%\" (
echo Device was found on %%d: && set folderfound=%%d:\%folder%\
) else (
echo Device was not found on %%d:
)
)
You need to use the
for /rloop to iterate directories recursively:Short explanation:
the
pushdcommand switched to the drive with the letter stored in%%d.The
for /rloop starts at\(the root directory of the currently selectly drive), and iterates runs all sub-directories.popdreturns to the directory beforepushdwas called.This is just an example of how your loop should now look like. Everything else remains the same.
By the way, you are using
:autodetect1in your script, but it is not defined anywhere…