How to get windows batch's parent folder

会有一股神秘感。 提交于 2019-11-27 04:41:11

问题


I'm writing a batch file, I need to get the parent folder of this bat file. Is it possibile? NB I mean the parent folder of the batch file not of the current directory of the prompt calling that batch.

Thanks


回答1:


The parent folder of a Batch is in the Variable %~dp0 located. Example:

@echo off&setlocal
for %%i in ("%~dp0.") do set "folder=%%~fi"
echo %folder%


来源:https://stackoverflow.com/questions/16623780/how-to-get-windows-batchs-parent-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!