for substring

Here is how you extract the various elements from a fully qualified file name:

@echo off
set my_file=C:\path\to\dir\test.xls
for /F %%a in ('echo %my_file%') do (
  echo Drive=%%~da
  echo Path=%%~pa
  echo Name=%%~na
  echo Extension=%%~xa
)

posted @ 2017-06-20 15:49  一块橡皮  阅读(73)  评论(0编辑  收藏  举报