简体   繁体   中英

getting filename part of a path in windows batch script

In a batch script, I have a batch var %filePath% that has the path to a file. If I want to extract just the filename part from it, what is the command for that?

Thanks!

try this:

 for /f "delims=" %%i in ("%filePath%") do set "fileName=%%~nxi"
 echo %fileName%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM