I updated the answer, now it also searches in sub-folders of the parent and child folders. MaxLevel is a delimiter for parent folders meaning don't go any deeper than that "parent folder"
For example if you have "Folder_F" as input and want to search for a folder called "my folder" and MaxLevel is "Desktop". It would ...
You can use the way, the parser works to "split" the current folder (%cd%) into the desired base path and "commenting out" the rest:
set folder=%cd:\SomeFolder\=\SomeFolder&REM %
Run it with echo off to watch the "magic" happen.
Read the output of set /? to learn how the substring substitution works.
You can also use sudo env PATH=$PATH ...rest_of_command_here.... Since that's not so convenient to type, I've added an alias alias sudop='sudo env PATH=$PATH'. The sudop (rather than aliasing sudo itself) is a reminder to me to make me aware that I am preserving my current environment path.
I would like to know the full list of variables that I can use in Windows Explorer or related relative paths that is accepted by Windows 10. Variables like %appdata%, %userprofile%, %windir%...etc.
You can list the system's environmental variables by running the following PowerShell command:
Get-ChildItem Env: | Sort Name
Any variable that contains a path, ...
If you want to see the list of paths available such as %AppData% and similar then simply open a command prompt and type set. You will see something like
APPDATA=C:\Users\<your user profile>\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
Batch file programming is messy.
I can’t find any one solution that works perfectly.
But this three-pronged approach seems to work:
:: Assume/anticipate failure
cd /d "%INPUT_PATH%\%REL_PATH%" 2> nul && (
if exist %FOLDER_NAME%\ set "FOLDER_EXIST=True"