@echo
cd\
cd C:\Test\pdf
for /f "delims=" %%i in ('dir /b | findstr /E /R "\\BW RRI - [0-9]\.[0-9]\PAYMENT CONFIRMATION.pdf$"') do set "Filename=%%i" ren ("%FileName%" "test.pdf")
EXIT
So i am trying to run above batch to find a file and rename it. Filename has space. When i run just the following command in command prompt it finds the right file
dir /b | findstr /E /R "\\BW RRI - [0-9]\.[0-9]\PAYMENT CONFIRMATION.pdf$"
But when i use for loop to rename it, it does not work. what am i doing wrong ?