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

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

问题描述

我正在写一个批处理文件,我需要获取这个bat文件的父文件夹.有可能吗?注意我的意思是批处理文件的父文件夹,而不是调用该批处理的提示的当前目录.

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.

谢谢

推荐答案

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天全站免登陆