Change the syntax set...:
set yourFolderPath="n:\xxxx\xxxx\%xxxx%"
... to the following (in general):
set "yourFolderPath=n:\xxxx\xxxx\%xxxx%"
So, quotation marks are no longer part of the meaning. Since you have this in your question, loop for /R( for /R "%yourFolderPath%") gets the root path, for example for /R ""n:\xxxx\xxxx\%xxxx%"", therefore it is "retrained". This is a problem, especially if there are white spaces and / or special characters in the variable.
set : , , , - , :
set PDIR="D:\Data"
set FILE="file.ext"
:
echo unquoted: %PDIR%\%FILE%
echo quoted: "%PDIR%\%FILE%"
:
unquoted: "D:\Data"\"file.ext"
quoted: ""D:\Data"\"file.ext""
, . :
set "PDIR=D:\Data"
set "FILE=file.ext"
echo unquoted: %PDIR%\%FILE%
echo quoted: "%PDIR%\%FILE%"
, :
unquoted: D:\Data\file.ext
quoted: "D:\Data\file.ext"
, .
, , Windows cmd .