A variable %result%
contains the path "D:\My Folder1\My Folder 2\My Folder 3\The Important File.txt"
. I want to store The Important File
in some another variable. That is, I want to extract the file name (Without extention) from a full path.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This should give you what you need.
@echo off
for %%a in ("%result%") do set "newvariable=%%~na"
回答2:
You'll find a solution here: Get the file name from a full or relative path knowing that this one is not a parameter of the batch
here: Get filename from string-path?
here: In Batch: Read only the filename from a variable with path and filename
Please search existing questions before creating duplicates.