I know that you can parse complete file path names easily when expanding batch file parameters.
For example, you may execute the following command line:
PROCESS.BAT C:WINDOWS\NOTEPAD.EXE
where process.bat contains the following line:
@ECHO %~NX1
The results would be:
NOTEPAD.EXE
But is there a way to easily parse environment variables in a siimilar way? or a way to convert the environment variable into a parameter so I may use these file name parsing functions on it?
extracting file name from an environment variiable
Moderator: DosItHelp
-
- Posts: 319
- Joined: 12 May 2006 01:13
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Code: Select all
@echo off
set "testvar=c:\tmp\test.txt"
call :process %testvar%
goto :eof
:process
echo %~nx1
goto :eof