I get the EXE files from a Polyspace-Config and then I want to rename them all with "result_" in front.
But something is wrong:
@echo off
FOR /f "tokens=*" %%G IN ('dir C:\PolyspaceProjects\*_exe* /b') DO (
set filename = %%G
set prefix = result_
echo %prefix%%filename%
)
This solves it (must use !
instead of %
when echoing the variable and need setlocal enabledelayedexpansion
): %%F variable always referencing the last item in a FOR loop instead of the current one
And this link explains things pretty well: https://ss64.com/nt/for_f.html
@echo off
cls
setlocal enabledelayedexpansion
FOR /f "tokens=*" %%G IN ('dir C:\temp\*Gold* /b') DO (
SET dog=%%G
echo !dog!
echo %%G
)
This is what I did for now... WORKS (would have liked to have used SET and variables for future modifications):
@echo off
cls
setlocal enabledelayedexpansion
FOR /f "tokens=*" %%G IN ('dir C:\PolyspaceProjects\*_exe* /b') DO (
rem Remove the file extension in the string
for /f "tokens=1 delims=." %%A in ("%%G") do (
echo polyspace-bug-finder -options-file c:\PolyspaceProjects\%%G -options-file "C:\PolyspaceProjects\BugFinderOptions.psops" -results-dir results_%%A
)
)