如何批量从完整路径中拆分文件名?

问题描述:

如何在批处理脚本中将文件名从完整路径中分离出来?

How do I split the filename out of a full path in batch scripting?

@echo off
Set filename=C:Documents and SettingsAll UsersDesktopDostips.cmd
For %%A in ("%filename%") do (
    Set Folder=%%~dpA
    Set Name=%%~nxA
)
echo.Folder is: %Folder%
echo.Name is: %Name%

但我不能相信这一点;Google 在 http://www.dostips.com/forum 上找到了这个/viewtopic.php?f=3&t=409

But I can't take credit for this; Google found this at http://www.dostips.com/forum/viewtopic.php?f=3&t=409