You have a fair bit to learn if you want to do something this complicated directly from a batch file.
Research list:
FOR
SET
CALL
You'll want to use the FOR
command to get the filename; pay attention to the %~
options. For example:
set BAT_DGNFNM=
for %%F in (*.dgn) do set BAT_DGNFNM=%%~nF
This causes the environment variable BAT_DGNFNM
to be set to the base filename. However, it loops through all the files, so really, you need it to call a subroutine for each file:
for %%F in (*.dgn) do call :DODGN "%%~dpnxF" "%%~nF"
This calls the subroutine :DODGN
and passes it two quote-encapsulated parameters; the first one is the fully-qualified filename and the second one is simply the base filename.
Then you do the actual file handling in the subroutine:
:DODGN
set BAT_DGNFNM=%1
set BAT_DGNBNM=%2
REM Do stuff with BAT_DGNBNM using SET commands
GOTO :EOF
You'll need to make sure you don't "fall through" to the subroutine after the main loop is done, and you should clean up your environment variables when you're done, so this would look something like:
@echo off
for %%F in (*.dgn) do call :DODGN "%%~dpnxF" "%%~nF"
goto ENDIT
:DODGN
set BAT_DGNFNM=%1
set BAT_DGNBNM=%2
REM Do stuff with BAT_DGNBNM using SET commands
GOTO :EOF
:ENDIT
set BAT_DGNFNM=
set BAT_DGNBNM=
Good luck -- this stuff can get complicated.
Final reminder: Most of your learning curve will be with the SET
command -- that's how you extract substrings out of one environment variable and put it into another, perform text replacement, etc.
This stuff is way easier in VBS or PowerShell.