I suggest to use for your batch file:
@echo off
if "%~1" == "" goto ShowHelp
if "%~1" == "/?" goto ShowHelp
rem Get just file name without file extension and path.
set "BitFileName=%~n1"
rem Get drive and path of file ending with a backslash.
set "BitFilePath=%~dp1"
xmd.exe -tcl ./genace.tcl -jprog -hw "%BitFilePath%%BitFileName%.bit" -board ml505 -ace "%BitFilePath%my_%BitFileName%.ace"
set "BitFileName="
set "BitFilePath="
echo.
goto :EOF
:ShowHelp
echo Makeace - by FPGA Developer http://www.fpgadeveloper.com
echo.
echo Usage: makeace bitfile
echo.
echo Example: makeace project
echo.
pause
Now it does not matter if the batch file is called with file name having .bit
appended or not. And it works now also for file names with 1 or more spaces or other characters listed on last help page output by running cmd /?
in a command prompt window.
:EOF
is a predefined label which must not be explicitly defined in the batch file. goto :EOF
is like exit /B
, i.e. exit this batch file and continue with command processing in parent process which means exiting command processor if the parent process is the command process cmd.exe
called without /K
to keep command prompt window open after finishing batch processing.
For understanding the used commands and how they work, open a command prompt window, execute there the following commands, and read entirely all help pages displayed for each command very carefully.
call /?
... explains %~1
, %~n1
and %~dp1
.
echo /?
goto /?
if /?
pause /?
rem /?
set /?