My batch file is throwing error when run, but when I run the commands one by one manually in command line then I get no error. Here's the batch file 'test.bat'.
echo "test"
cd "c:\packages"
pause
for /R c:\packages %F in (*.msi) do set /A servername=%~nxF
pause
echo %servername%
pause
I get this error - "~nxF was unexpcted at this time".
I got the sample code from https://stackoverflow.com/a/1100466/1105556 I'm just trying the get the file name in c:\packages & store the value in 'servername' variable. There is only one file (.msi) in the folder I cant figure out whats wrong. Can someone please solve the riddle for me?