我有一个存储在c:\data\profile\script.bat
目录中的批处理文件。 我SCRIPT.DAT包含:如何获得批处理文件的路径
@echo off
echo %~dp0%
pause
如果我运行它,将显示在屏幕上c:\data\profile\
。但那不是我想要的。我想在屏幕上显示c:\data\
。为此,我必须改变我的批次包含:
@echo off
echo %~dp0:~0,8%
pause
然后我运行该文件,但屏幕只显示c:\data\profile\:~0,8
。 请让我知道如何做到这一点?
的可能的复制[在批处理文件中执行子字符串的最佳方法是什么?](http://stackoverflow.com/questions/636381/what-is-the-best-way-to-do-a-substring-in-a -batch-file) – Marged
你有没有试过写在那里:http://stackoverflow.com/questions/636381/what-is-the-best-way-to-do-a-substring-in-a-batch-文件 – Marged