我编写了一个函数,它从完整路径字符串中获取文件名。 但是我写的子程序执行起来花费了太多时间(大约 4 秒)。我试图理解为什么。
这是批处理文件
@echo off
set fullPath=\\server\Dir1\Dir Number 2\Dir3\Dir4\abc.txt
echo %fullPath%
call:giveFileName "%fullPath%" finalName
echo After Function call fileName: %finalName% Good Job
goto:eof
:giveFileName
SETLOCAL
set fileName=%~nX1
::echo here is fileNmae %fileName%
(ENDLOCAL&set %~2=%fileName%
)
goto:eof
最佳答案
我相信正在尝试定位 \\server\Dir1\Dir Number 2\Dir3\Dir4\abc.txt
当然,寻找该服务器的成本很高。
如果您删除 \\server
,它就相当光滑了。
关于windows - 批处理文件功能执行时间过长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17398344/