So to cut my question a bit shorter than before, i want to have a batch file on my desktop and from running it from the desktop, i want to search the computer for a Folder named(Visuals2579211). This folder has an app/exe i made inside it along with log, tmp and txt files.
The problem is i have more than one computer running windows, some are running windows: Visa, Win7 Win8 Win10. I use this application a lot on my machines and there are tasks i want to do to the folder the app is in using a BATCH file, tasks such as searching txt files for strings, exporting data, deleting files etc. The folder name never changes on any of the machines(Visuals2579211), however none of my machines really has this app installed in the same location/drive letter some of the drives arent even called C: etc. It is very tiresome having to manually access these files on all of these machines and change them all the time when i could make a batch to do it for me.
So i need help in finding a way to search the PC from the desktop running BATCH to locate the folder name "Visuals2579211" and after finding the folder, if it exists, store the location/address of the folder as a PATH to later use for file manipulation. "foxidrive" had a very helpful solution:
Code: Select all
@echo off
set "folder="
for %%a in (c e f) do if not defined folder (
pushd "%%a:\"
for /d /r %%b in (Visua?s2579211) do set "folder=%%b"
popd
)
if defined folder %comspec% /k pushd "%folder%"
But instead of making the BATCH make this folder the CD, i would rather make it a PATH/String. Can someone please help me in maybe altering foxidrives solution or provide a better one and if possible please add as much comments as you can to the code as i really would like to understand the code more too.
Thanks.