如何获取Windows批量的父文件夹 [英] How to get windows batch's parent folder

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

问题描述

我在写一个批处理文件,我需要得到这个蝙蝠文件的父文件夹。它是不可能性?
注:我的意思是批处理文件不是及时调用该批次的当前目录的父文件夹。

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.

感谢

推荐答案

一个批次的父文件夹是在变量%〜DP0 位置。例如:

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%

这篇关于如何获取Windows批量的父文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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