批处理文件:获取父目录的绝对路径 [英] Batch file: get absolute path of parent directory

查看:81
本文介绍了批处理文件:获取父目录的绝对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到一种情况,需要获取当前正在执行的批处理文件的父目录。在google和stackoverflow上搜索了解决方案,但可以找到一个干净而简单的解决方案。

I recently came across to a situation where need to fetch parent directory of currently being executed batch file. Searched for the solution on google and stackoverflow but could find a clean and easy solution.

推荐答案

不知道这是不是你自己

@echo off
for %%a in ("%~dp0\.") do echo "%%~dpnxa"
for %%a in ("%~dp0\.") do for %%b in ("%%~dpa\.") do echo "%%~dpnxb"
pause

这篇关于批处理文件:获取父目录的绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆