变量%result%
包含路径"D:\My Folder1\My Folder 2\My Folder 3\The Important File.txt"
。我想将The Important File
存储在另一个变量中。也就是说,我想从完整路径中提取文件名(无扩展名)。
答案 0 :(得分:2)
您可以在此处找到解决方案:Get the file name from a full or relative path knowing that this one is not a parameter of the batch
此处:Get filename from string-path?
此处:In Batch: Read only the filename from a variable with path and filename
请在创建重复项之前搜索现有问题。
答案 1 :(得分:2)
这应该可以满足您的需求。
@echo off
for %%a in ("%result%") do set "newvariable=%%~na"